pub struct GroupId(/* private fields */);Expand description
The sealed-envelope types, re-exported so that every path into them keeps working and there is still exactly one definition of each.
They live in offline-protocol-sealed because a leaf node encodes and
decodes the same envelope this crate does, and cannot link this crate:
this one is built on OpenMLS, which needs std. See ADR 0022.
Unique identifier for an MLS group.
Group ids flow from the wire into 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 = MAX_STRING_FIELD_LEN
pub const MAX_LEN: usize = MAX_STRING_FIELD_LEN
Maximum accepted group id length in bytes.
This is the compact wire format’s string-field cap, not a copy of it: a group id that could not survive a round trip through the envelope must not be constructible in the first place.
Sourcepub fn new(id: impl Into<String>) -> Result<GroupId, SealedError>
pub fn new(id: impl Into<String>) -> Result<GroupId, SealedError>
Creates a new group ID, rejecting storage-hostile values.
Sourcepub fn for_session(user_a: &str, user_b: &str) -> Result<GroupId, SealedError>
pub fn for_session(user_a: &str, user_b: &str) -> Result<GroupId, SealedError>
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: D,
) -> Result<GroupId, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
fn deserialize<D>(
deserializer: D,
) -> Result<GroupId, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
impl Eq for GroupId
Source§impl Serialize for GroupId
impl Serialize for GroupId
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
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