pub struct OpenMlsService<S: DeMlsStorage> { /* private fields */ }Expand description
OpenMLS-backed MLS service, scoped to a single conversation. Owns
one MlsGroup plus an optional staged-commit slot for the inbound
stage→merge/discard pipeline. Credentials are Arc<MlsCredentials>
so one user’s keypair backs every per-conversation service.
Implementations§
Source§impl<S: DeMlsStorage> OpenMlsService<S>
impl<S: DeMlsStorage> OpenMlsService<S>
Sourcepub fn new_as_creator(
conversation_id: String,
storage: S,
credentials: Arc<MlsCredentials>,
) -> Result<Self, MlsError>
pub fn new_as_creator( conversation_id: String, storage: S, credentials: Arc<MlsCredentials>, ) -> Result<Self, MlsError>
Create a fresh MLS group as the sole initial member (“creator”).
Sourcepub fn new_from_welcome(
welcome_bytes: &[u8],
storage: S,
credentials: Arc<MlsCredentials>,
) -> Result<Option<Self>, MlsError>
pub fn new_from_welcome( welcome_bytes: &[u8], storage: S, credentials: Arc<MlsCredentials>, ) -> Result<Option<Self>, MlsError>
Try to join a group from a serialized welcome.
Returns Ok(None) when the welcome doesn’t address one of our key
packages — that’s the “not for us” branch, not an error. On
Ok(Some(svc)) the caller has a fully initialized service for the
group the welcome described.
Sourcepub fn generate_key_package(
storage: &S,
credentials: &MlsCredentials,
) -> Result<KeyPackageBytes, MlsError>
pub fn generate_key_package( storage: &S, credentials: &MlsCredentials, ) -> Result<KeyPackageBytes, MlsError>
Generate a single-use key package for credentials backed by storage.
Takes only storage + credentials rather than &self, so a joiner
can publish a key package before any MLS group has been created.
The resulting hash ref is registered in storage so a later
new_from_welcome can identify the welcome as “for us”.
Trait Implementations§
Source§impl<S> MlsService for OpenMlsService<S>where
S: DeMlsStorage,
impl<S> MlsService for OpenMlsService<S>where
S: DeMlsStorage,
Source§fn conversation_id(&self) -> &str
fn conversation_id(&self) -> &str
Source§fn delete(&mut self) -> Result<(), MlsError>
fn delete(&mut self) -> Result<(), MlsError>
Source§fn members(&self) -> Result<Vec<Vec<u8>>, MlsError>
fn members(&self) -> Result<Vec<Vec<u8>>, MlsError>
Source§fn current_epoch(&self) -> Result<u64, MlsError>
fn current_epoch(&self) -> Result<u64, MlsError>
Source§fn create_commit_candidate(
&mut self,
updates: &[MlsCommitInput],
) -> Result<CommitCandidate, MlsError>
fn create_commit_candidate( &mut self, updates: &[MlsCommitInput], ) -> Result<CommitCandidate, MlsError>
Source§fn merge_own_commit(&mut self) -> Result<(), MlsError>
fn merge_own_commit(&mut self) -> Result<(), MlsError>
create_commit_candidate
when our candidate has won the freeze round.Source§fn discard_own_commit(&mut self) -> Result<(), MlsError>
fn discard_own_commit(&mut self) -> Result<(), MlsError>
create_commit_candidate:
drop the pending commit and the pending proposals it contained.Source§fn stage_remote_commit(
&mut self,
proposals: &[Vec<u8>],
commit_bytes: &[u8],
) -> Result<StagedCandidateResult, MlsError>
fn stage_remote_commit( &mut self, proposals: &[Vec<u8>], commit_bytes: &[u8], ) -> Result<StagedCandidateResult, MlsError>
Source§fn merge_staged_commit(&mut self) -> Result<(), MlsError>
fn merge_staged_commit(&mut self) -> Result<(), MlsError>
Source§fn discard_staged_commit(&mut self) -> Result<(), MlsError>
fn discard_staged_commit(&mut self) -> Result<(), MlsError>
stage_remote_commit:
drop the staged commit and clear the pending proposals it
staged on top of.Source§fn encrypt(&mut self, plaintext: &[u8]) -> Result<Vec<u8>, MlsError>
fn encrypt(&mut self, plaintext: &[u8]) -> Result<Vec<u8>, MlsError>
Source§fn build_message(
&mut self,
app_msg: &AppMessage,
app_id: &[u8],
) -> Result<OutboundPacket, MlsError>
fn build_message( &mut self, app_msg: &AppMessage, app_id: &[u8], ) -> Result<OutboundPacket, MlsError>
app_msg and wrap the result as an
OutboundPacket on the application subtopic. The convenience
path most senders use.Source§fn decrypt_application_only(
&mut self,
ciphertext: &[u8],
) -> Result<DecryptResult, MlsError>
fn decrypt_application_only( &mut self, ciphertext: &[u8], ) -> Result<DecryptResult, MlsError>
Application messages,
silently ignoring anything else (including proposals and commits).
This guards the app subtopic against MLS-state pollution from
peers that misroute control messages.Source§fn decrypt(&mut self, ciphertext: &[u8]) -> Result<DecryptResult, MlsError>
fn decrypt(&mut self, ciphertext: &[u8]) -> Result<DecryptResult, MlsError>
Application messages and stores
incoming proposals as pending. Commits are out of scope here —
route them through
stage_remote_commit so they pass
the validation pipeline.Source§fn inspect_message_kind(
&self,
message_bytes: &[u8],
) -> Result<MlsMessageKind, MlsError>
fn inspect_message_kind( &self, message_bytes: &[u8], ) -> Result<MlsMessageKind, MlsError>
Source§fn commit_batch_max(&self) -> usize
fn commit_batch_max(&self) -> usize
DEFAULT_COMMIT_BATCH_MAX; impls may
override per-instance.Auto Trait Implementations§
impl<S> !Freeze for OpenMlsService<S>
impl<S> RefUnwindSafe for OpenMlsService<S>where
S: RefUnwindSafe,
impl<S> Send for OpenMlsService<S>where
S: Send,
impl<S> Sync for OpenMlsService<S>where
S: Sync,
impl<S> Unpin for OpenMlsService<S>where
S: Unpin,
impl<S> UnsafeUnpin for OpenMlsService<S>where
S: UnsafeUnpin,
impl<S> UnwindSafe for OpenMlsService<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