Skip to content

Commit

Permalink
core: Implement FromStr for ObjectUuid and ServiceUuid
Browse files Browse the repository at this point in the history
  • Loading branch information
dennis-hamester committed Nov 26, 2023
1 parent 1074ba7 commit 0847917
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion core/src/ids.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ use crate::error::{DeserializeError, SerializeError};
use crate::value_deserializer::{Deserialize, Deserializer};
use crate::value_serializer::{Serialize, Serializer};
use std::fmt;
use uuid::Uuid;
use std::str::FromStr;
use uuid::{Error as UuidError, Uuid};

/// Id of an object.
///
Expand Down Expand Up @@ -98,6 +99,14 @@ impl fmt::Display for ObjectUuid {
}
}

impl FromStr for ObjectUuid {
type Err = UuidError;

fn from_str(s: &str) -> Result<Self, UuidError> {
s.parse().map(Self)
}
}

/// Cookie of an object.
///
/// [`ObjectCookie`s](Self) are chosen by the broker when creating an object. They ensure that
Expand Down Expand Up @@ -256,6 +265,14 @@ impl fmt::Display for ServiceUuid {
}
}

impl FromStr for ServiceUuid {
type Err = UuidError;

fn from_str(s: &str) -> Result<Self, UuidError> {
s.parse().map(Self)
}
}

/// Cookie of a service.
///
/// [`ServiceCookie`s](Self) are chosen by the broker when creating a service. They ensure that
Expand Down

0 comments on commit 0847917

Please sign in to comment.