Struct ruma_common::DeviceId
source · [−]#[repr(transparent)]pub struct DeviceId(_);
Expand description
A Matrix key ID.
Device identifiers in Matrix are completely opaque character sequences. This type is provided simply for its semantic value.
Example
use ruma_common::{device_id, DeviceId, OwnedDeviceId};
let random_id = DeviceId::new();
assert_eq!(random_id.as_str().len(), 8);
let static_id = device_id!("01234567");
assert_eq!(static_id.as_str(), "01234567");
let ref_id: &DeviceId = "abcdefghi".into();
assert_eq!(ref_id.as_str(), "abcdefghi");
let owned_id: OwnedDeviceId = "ijklmnop".into();
assert_eq!(owned_id.as_str(), "ijklmnop");
Implementations
sourceimpl DeviceId
impl DeviceId
sourcepub fn new() -> OwnedDeviceId
Available on crate feature rand
only.
pub fn new() -> OwnedDeviceId
rand
only.Generates a random DeviceId
, suitable for assignment to a new device.
Trait Implementations
sourceimpl AsRef<DeviceId> for OwnedDeviceId
impl AsRef<DeviceId> for OwnedDeviceId
sourceimpl Borrow<DeviceId> for OwnedDeviceId
impl Borrow<DeviceId> for OwnedDeviceId
sourceimpl<'de> Deserialize<'de> for Box<DeviceId>
impl<'de> Deserialize<'de> for Box<DeviceId>
sourcefn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
sourceimpl From<&DeviceId> for OwnedDeviceId
impl From<&DeviceId> for OwnedDeviceId
sourcefn from(id: &DeviceId) -> OwnedDeviceId
fn from(id: &DeviceId) -> OwnedDeviceId
Converts to this type from the input type.
sourceimpl From<OwnedDeviceId> for Box<DeviceId>
impl From<OwnedDeviceId> for Box<DeviceId>
sourcefn from(a: OwnedDeviceId) -> Box<DeviceId>
fn from(a: OwnedDeviceId) -> Box<DeviceId>
Converts to this type from the input type.
sourceimpl PartialEq<Box<DeviceId, Global>> for &DeviceId
impl PartialEq<Box<DeviceId, Global>> for &DeviceId
sourceimpl PartialEq<Box<DeviceId, Global>> for DeviceId
impl PartialEq<Box<DeviceId, Global>> for DeviceId
sourceimpl PartialEq<OwnedDeviceId> for &DeviceId
impl PartialEq<OwnedDeviceId> for &DeviceId
sourcefn eq(&self, other: &OwnedDeviceId) -> bool
fn eq(&self, other: &OwnedDeviceId) -> bool
sourceimpl PartialEq<OwnedDeviceId> for Box<DeviceId>
impl PartialEq<OwnedDeviceId> for Box<DeviceId>
sourcefn eq(&self, other: &OwnedDeviceId) -> bool
fn eq(&self, other: &OwnedDeviceId) -> bool
sourceimpl PartialEq<OwnedDeviceId> for DeviceId
impl PartialEq<OwnedDeviceId> for DeviceId
sourcefn eq(&self, other: &OwnedDeviceId) -> bool
fn eq(&self, other: &OwnedDeviceId) -> bool
sourceimpl PartialOrd<DeviceId> for DeviceId
impl PartialOrd<DeviceId> for DeviceId
sourcefn partial_cmp(&self, other: &DeviceId) -> Option<Ordering>
fn partial_cmp(&self, other: &DeviceId) -> Option<Ordering>
1.0.0 · sourceconst fn le(&self, other: &Rhs) -> bool
const fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for
self
and other
) and is used by the <=
operator. Read moresourceimpl ToOwned for DeviceId
impl ToOwned for DeviceId
type Owned = OwnedDeviceId
type Owned = OwnedDeviceId
The resulting type after obtaining ownership.
sourcefn to_owned(&self) -> Self::Owned
fn to_owned(&self) -> Self::Owned
Creates owned data from borrowed data, usually by cloning. Read more
1.63.0 · sourcefn clone_into(&self, target: &mut Self::Owned)
fn clone_into(&self, target: &mut Self::Owned)
Uses borrowed data to replace owned data, usually by cloning. Read more
impl Eq for DeviceId
impl StructuralEq for DeviceId
impl StructuralPartialEq for DeviceId
Auto Trait Implementations
impl RefUnwindSafe for DeviceId
impl Send for DeviceId
impl !Sized for DeviceId
impl Sync for DeviceId
impl Unpin for DeviceId
impl UnwindSafe for DeviceId
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
sourcefn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key
and return true
if they are equal.