Skip to content

Commit

Permalink
use Uuid:::from_u128 for uuid_to_string (#1362)
Browse files Browse the repository at this point in the history
  • Loading branch information
fft001 authored Jul 18, 2024
1 parent 9f7bf4c commit 61318d9
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/serializers/type_serializers/uuid.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
use std::borrow::Cow;

use pyo3::prelude::*;
use pyo3::types::PyDict;
use pyo3::{intern, prelude::*};
use uuid::Uuid;

use crate::definitions::DefinitionsBuilder;

Expand All @@ -11,7 +12,10 @@ use super::{
};

pub(crate) fn uuid_to_string(py_uuid: &Bound<'_, PyAny>) -> PyResult<String> {
Ok(py_uuid.str()?.to_string())
let py = py_uuid.py();
let uuid_int_val: u128 = py_uuid.getattr(intern!(py, "int"))?.extract()?;
let uuid = Uuid::from_u128(uuid_int_val);
Ok(uuid.to_string())
}

#[derive(Debug, Clone)]
Expand Down

0 comments on commit 61318d9

Please sign in to comment.