pub struct GlobalId { /* private fields */ }
Expand description
This type is used to hold the ID of a message, room, person etc. It is created from a certain resource type to make it impossible to use a person ID to fetch a message, or vice versa.
Implementations§
source§impl GlobalId
impl GlobalId
sourcepub fn new(type_: GlobalIdType, id: String) -> Result<Self, Error>
pub fn new(type_: GlobalIdType, id: String) -> Result<Self, Error>
Create a new GlobalId
, with an ID type as well as an API ID (which can be either old
UUID-style, or new base64 URI style).
sourcepub fn new_with_cluster(
type_: GlobalIdType,
id: String,
cluster: Option<&str>
) -> Result<Self, Error>
pub fn new_with_cluster( type_: GlobalIdType, id: String, cluster: Option<&str> ) -> Result<Self, Error>
Given an ID and a possible cluster, generate a new geo-ID.
Will fail if given a GlobalIdType
that doesn’t correspond to a particular type (message, room,
etc.)
Arguments
type_: GlobalIdType
- the type of the ID being constructedid: String
- the ID, either old (UUID) or new (base64 geo-ID)cluster: Option<&str>
- cluster for geo-ID. Only used if the ID is an old-style UUID. Will default to"us"
if not given and can’t be determined from the ID - this should work for most requests.
Errors
ErrorKind::Msg
if:- the ID type is
GlobalIdType::Unknown
. - the ID is a base64 geo-ID that does not follow the format
ciscospark://[cluster]/[type]/[id]
. - the ID is a base64 geo-ID and the type does not match the given type.
- the ID is a base64 geo-ID and the cluster does not match the given cluster.
- the ID is neither a UUID or a base64 geo-id.
- the ID type is
sourcepub fn new_with_cluster_unchecked(
type_: GlobalIdType,
id: String,
cluster: Option<&str>
) -> Self
pub fn new_with_cluster_unchecked( type_: GlobalIdType, id: String, cluster: Option<&str> ) -> Self
Given an ID and a possible cluster, generate a new geo-ID.
Skips all checks. (If something wrong is passed, for example a GlobalIdType::Unknown
,
this will silently produce a bad ID that will always return a 404 from the API.)
sourcepub fn check_type(&self, expected_type: GlobalIdType) -> Result<(), Error>
pub fn check_type(&self, expected_type: GlobalIdType) -> Result<(), Error>
Check if type is the same as expected type
Trait Implementations§
Auto Trait Implementations§
impl RefUnwindSafe for GlobalId
impl Send for GlobalId
impl Sync for GlobalId
impl Unpin for GlobalId
impl UnwindSafe for GlobalId
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more