pub struct GroupId(/* private fields */);Expand description
Unique identifier for an MLS group.
Group ids flow from the wire into crate::storage::MlsStorage as raw
key_id storage keys, so they are validated at construction: one or more
non-empty colon-separated segments (: is the namespace separator used by
session:<a>:<b> and group:<uuid> ids), each segment subject to the
same storage-key policy as UserId/AppId (no path-traversal components,
control characters, /, or \), with a total length cap of
GroupId::MAX_LEN.
Implementations§
Source§impl GroupId
impl GroupId
Sourcepub const MAX_LEN: usize = 4096
pub const MAX_LEN: usize = 4096
Maximum accepted group id length in bytes.
Matches the EncryptedMessage compact wire format’s string-field cap.
Sourcepub fn new(id: impl Into<String>) -> Result<Self>
pub fn new(id: impl Into<String>) -> Result<Self>
Creates a new group ID, rejecting storage-hostile values.
Sourcepub fn for_session(user_a: &str, user_b: &str) -> Result<Self>
pub fn for_session(user_a: &str, user_b: &str) -> Result<Self>
Builds the deterministic group ID for a 1:1 session, rejecting storage-hostile user ids (the id becomes a raw storage key).
Both peers must land on the same string, so the two ids are put in a
canonical order. When both are addresses that order is
Address order — the underlying hash
bytes — because the bech32 charset is not ASCII-monotonic (value 4
renders as y 0x79, value 5 as 9 0x39), so sorting the rendered
strings would disagree with every other address comparison in the
protocol. Ids that are not both addresses fall back to string order,
which is all a nickname id has.
Either way the result is symmetric in its arguments, which is the property peers actually depend on.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for GroupId
impl<'de> Deserialize<'de> for GroupId
Source§fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>
fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>
impl Eq for GroupId
impl StructuralPartialEq for GroupId
Auto Trait Implementations§
impl Freeze for GroupId
impl RefUnwindSafe for GroupId
impl Send for GroupId
impl Sync for GroupId
impl Unpin for GroupId
impl UnsafeUnpin for GroupId
impl UnwindSafe for GroupId
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Declassify for T
impl<T> Declassify for T
type Declassified = T
fn declassify(self) -> T
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more