pub struct MlsService<S: DeMlsStorage> { /* private fields */ }Expand description
Main MLS service - unified API for all MLS operations.
Groups are managed internally by group ID string. The service handles:
- Identity initialization and management
- Key package generation
- Group creation and joining
- Message encryption and decryption
- Steward commit operations
Implementations§
Source§impl<S> MlsService<S>where
S: DeMlsStorage<MlsStorage = MemoryStorage>,
impl<S> MlsService<S>where
S: DeMlsStorage<MlsStorage = MemoryStorage>,
Sourcepub fn init(&self, wallet: Address) -> Result<()>
pub fn init(&self, wallet: Address) -> Result<()>
Initialize identity from wallet address.
Creates MLS credentials and signing keys from the wallet address. Call this once before using any other methods.
Sourcepub fn wallet_hex(&self) -> String
pub fn wallet_hex(&self) -> String
Get the wallet address as a checksummed hex string (“0x…”).
Sourcepub fn generate_key_package(&self) -> Result<KeyPackageBytes>
pub fn generate_key_package(&self) -> Result<KeyPackageBytes>
Generate a key package for joining a group.
Key packages are single-use and should be regenerated after each join.
Sourcepub fn create_group(&self, group_id: &str) -> Result<()>
pub fn create_group(&self, group_id: &str) -> Result<()>
Create a new MLS group.
The group name becomes the MLS group ID. The creator becomes the only member and is typically the steward.
Sourcepub fn join_group(&self, welcome_bytes: &[u8]) -> Result<String>
pub fn join_group(&self, welcome_bytes: &[u8]) -> Result<String>
Join a group from a welcome message.
Returns the group ID on success. The welcome must be for us (contain one of our key package references).
Sourcepub fn is_welcome_for_us(&self, welcome_bytes: &[u8]) -> Result<bool>
pub fn is_welcome_for_us(&self, welcome_bytes: &[u8]) -> Result<bool>
Check if a welcome message is for us (without joining).
Returns true if the welcome contains one of our key package references.
Sourcepub fn members(&self, group_id: &str) -> Result<Vec<Vec<u8>>>
pub fn members(&self, group_id: &str) -> Result<Vec<Vec<u8>>>
Get all current group members as wallet addresses.
Sourcepub fn encrypt(&self, group_id: &str, plaintext: &[u8]) -> Result<Vec<u8>>
pub fn encrypt(&self, group_id: &str, plaintext: &[u8]) -> Result<Vec<u8>>
Encrypt an application message for the group.
Returns MLS ciphertext that only group members can decrypt.
Sourcepub fn decrypt(
&self,
group_id: &str,
ciphertext: &[u8],
) -> Result<DecryptResult>
pub fn decrypt( &self, group_id: &str, ciphertext: &[u8], ) -> Result<DecryptResult>
Decrypt/process an inbound MLS message.
Handles application messages, proposals, and commits.
Sourcepub fn commit(
&self,
group_id: &str,
updates: &[GroupUpdate],
) -> Result<CommitResult>
pub fn commit( &self, group_id: &str, updates: &[GroupUpdate], ) -> Result<CommitResult>
Create proposals for membership changes and commit them.
This is the core steward operation: takes a list of add/remove operations, creates MLS proposals, and commits them in a batch.
Auto Trait Implementations§
impl<S> !Freeze for MlsService<S>
impl<S> RefUnwindSafe for MlsService<S>where
S: RefUnwindSafe,
impl<S> Send for MlsService<S>
impl<S> Sync for MlsService<S>
impl<S> Unpin for MlsService<S>where
S: Unpin,
impl<S> UnwindSafe for MlsService<S>where
S: UnwindSafe,
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> Declassify for T
impl<T> Declassify for T
type Declassified = T
fn declassify(self) -> T
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