Skip to main content

OpenMlsService

Struct OpenMlsService 

Source
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>

Source

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”).

Source

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.

Source

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,

Source§

fn conversation_id(&self) -> &str

The conversation id this service is scoped to.
Source§

fn delete(&mut self) -> Result<(), MlsError>

Tear down all local MLS state for this conversation. Idempotent so repeated leave / cleanup is safe.
Source§

fn members(&self) -> Result<Vec<Vec<u8>>, MlsError>

Current conversation members as serialized credential bytes (one entry per leaf, in MLS leaf order).
Source§

fn is_member(&self, identity: &[u8]) -> bool

Whether identity is currently a member.
Source§

fn current_epoch(&self) -> Result<u64, MlsError>

Current MLS epoch. This is the single source of truth — never maintain a parallel counter at the app layer.
Source§

fn create_commit_candidate( &mut self, updates: &[MlsCommitInput], ) -> Result<CommitCandidate, MlsError>

Build a commit candidate from a list of membership changes and stage it locally. Returns the wire bytes (proposals + commit + an optional welcome) for the steward to broadcast. Read more
Source§

fn merge_own_commit(&mut self) -> Result<(), MlsError>

Apply our pending commit, advancing the MLS epoch. Call after a successful create_commit_candidate when our candidate has won the freeze round.
Source§

fn discard_own_commit(&mut self) -> Result<(), MlsError>

Roll back the local side effects of 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>

Validate and stage a remote commit candidate atomically: each proposal is processed and stored as MLS-pending, then the commit is processed against that pending set, producing a staged commit held internally. Read more
Source§

fn merge_staged_commit(&mut self) -> Result<(), MlsError>

Apply the previously staged inbound commit, advancing the MLS epoch. Errors if no commit is staged.
Source§

fn discard_staged_commit(&mut self) -> Result<(), MlsError>

Roll back 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>

Encrypt an application message for the conversation, returning the raw MLS wire bytes.
Source§

fn build_message( &mut self, app_msg: &AppMessage, app_id: &[u8], ) -> Result<OutboundPacket, MlsError>

Encode and encrypt 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>

Strict app-subtopic decrypt: accepts only 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>

General decrypt: accepts 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>

Peek the untrusted outer kind of an MLS wire message without processing or signature-checking it. Used for cheap pre-dispatch lane checks (e.g. “is this a proposal or a commit”).
Source§

fn commit_batch_max(&self) -> usize

Maximum number of MLS proposals the steward will pack into one commit batch. Defaults to 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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> Classify for T

Source§

type Classified = T

Source§

fn classify(self) -> T

Source§

impl<T> Declassify for T

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more