pub struct OutboundGroupSession { /* private fields */ }
Expand description
Outbound group session.
Outbound group sessions are used to exchange room messages between a group of participants. Outbound group sessions are used to encrypt the room messages.
Implementations§
Source§impl OutboundGroupSession
impl OutboundGroupSession
Sourcepub fn new(
device_id: OwnedDeviceId,
identity_keys: Arc<IdentityKeys>,
room_id: &RoomId,
settings: EncryptionSettings,
) -> Result<Self, SessionCreationError>
pub fn new( device_id: OwnedDeviceId, identity_keys: Arc<IdentityKeys>, room_id: &RoomId, settings: EncryptionSettings, ) -> Result<Self, SessionCreationError>
Create a new outbound group session for the given room.
Outbound group sessions are used to encrypt room messages.
§Arguments
-
device_id
- The id of the device that created this session. -
identity_keys
- The identity keys of the account that created this session. -
room_id
- The id of the room that the session is used in. -
settings
- Settings determining the algorithm and rotation period of the outbound group session.
Sourcepub fn add_request(
&self,
request_id: OwnedTransactionId,
request: Arc<ToDeviceRequest>,
share_infos: BTreeMap<OwnedUserId, BTreeMap<OwnedDeviceId, ShareInfo>>,
)
pub fn add_request( &self, request_id: OwnedTransactionId, request: Arc<ToDeviceRequest>, share_infos: BTreeMap<OwnedUserId, BTreeMap<OwnedDeviceId, ShareInfo>>, )
Add a to-device request that is sending the session key (or room key)
belonging to this OutboundGroupSession
to other members of the
group.
The request will get persisted with the session which allows seamless session reuse across application restarts.
Warning this method is only exposed to be used in integration tests of crypto-store implementations. Do not use this outside of tests.
Sourcepub fn withheld_code(&self, code: WithheldCode) -> RoomKeyWithheldContent
pub fn withheld_code(&self, code: WithheldCode) -> RoomKeyWithheldContent
Create a new m.room_key.withheld
event content with the given code for
this outbound group session.
Sourcepub fn invalidate_session(&self)
pub fn invalidate_session(&self)
This should be called if an the user wishes to rotate this session.
Sourcepub fn settings(&self) -> &EncryptionSettings
pub fn settings(&self) -> &EncryptionSettings
Get the encryption settings of this outbound session.
Sourcepub fn mark_request_as_sent(
&self,
request_id: &TransactionId,
) -> BTreeMap<OwnedUserId, BTreeSet<OwnedDeviceId>>
pub fn mark_request_as_sent( &self, request_id: &TransactionId, ) -> BTreeMap<OwnedUserId, BTreeSet<OwnedDeviceId>>
Mark the request with the given request id as sent.
This removes the request from the queue and marks the set of users/devices that received the session.
Sourcepub async fn encrypt(
&self,
event_type: &str,
content: &Raw<AnyMessageLikeEventContent>,
) -> Raw<RoomEncryptedEventContent>
pub async fn encrypt( &self, event_type: &str, content: &Raw<AnyMessageLikeEventContent>, ) -> Raw<RoomEncryptedEventContent>
Encrypt a room message for the given room.
Beware that a room key needs to be shared before this method
can be called using the share_room_key()
method.
§Arguments
-
event_type
- The plaintext type of the event, the outer type of the event will becomem.room.encrypted
. -
content
- The plaintext content of the message that should be encrypted in raw JSON form.
§Panics
Panics if the content can’t be serialized.
Sourcepub fn expired(&self) -> bool
pub fn expired(&self) -> bool
Check if the session has expired and if it should be rotated.
A session will expire after some time or if enough messages have been encrypted using it.
Sourcepub fn invalidated(&self) -> bool
pub fn invalidated(&self) -> bool
Has the session been invalidated.
Mark the session as shared.
Messages shouldn’t be encrypted with the session before it has been shared.
Check if the session has been marked as shared.
Sourcepub async fn session_key(&self) -> SessionKey
pub async fn session_key(&self) -> SessionKey
Get the session key of this session.
A session key can be used to to create an InboundGroupSession
.
Sourcepub fn sender_key(&self) -> Curve25519PublicKey
pub fn sender_key(&self) -> Curve25519PublicKey
Gets the Sender Key
Sourcepub fn session_id(&self) -> &str
pub fn session_id(&self) -> &str
Returns the unique identifier for this session.
Sourcepub async fn message_index(&self) -> u32
pub async fn message_index(&self) -> u32
Get the current message index for this session.
Each message is sent with an increasing index. This returns the message index that will be used for the next encrypted message.
Sourcepub fn from_pickle(
device_id: OwnedDeviceId,
identity_keys: Arc<IdentityKeys>,
pickle: PickledOutboundGroupSession,
) -> Result<Self, PickleError>
pub fn from_pickle( device_id: OwnedDeviceId, identity_keys: Arc<IdentityKeys>, pickle: PickledOutboundGroupSession, ) -> Result<Self, PickleError>
Restore a Session from a previously pickled string.
Returns the restored group session or a OlmGroupSessionError
if there
was an error.
§Arguments
-
device_id
- The device ID of the device that created this session. Put differently, our own device ID. -
identity_keys
- The identity keys of the device that created this session, our own identity keys. -
pickle
- The pickled version of theOutboundGroupSession
. -
pickle_mode
- The mode that was used to pickle the session, either an unencrypted mode or an encrypted using passphrase.
Sourcepub async fn pickle(&self) -> PickledOutboundGroupSession
pub async fn pickle(&self) -> PickledOutboundGroupSession
Store the group session as a base64 encoded string and associated data belonging to the session.
§Arguments
pickle_mode
- The mode that should be used to pickle the group session, either an unencrypted mode or an encrypted using passphrase.
Trait Implementations§
Source§impl Clone for OutboundGroupSession
impl Clone for OutboundGroupSession
Source§fn clone(&self) -> OutboundGroupSession
fn clone(&self) -> OutboundGroupSession
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreAuto Trait Implementations§
impl Freeze for OutboundGroupSession
impl !RefUnwindSafe for OutboundGroupSession
impl Send for OutboundGroupSession
impl Sync for OutboundGroupSession
impl Unpin for OutboundGroupSession
impl !UnwindSafe for OutboundGroupSession
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, W> HasTypeWitness<W> for Twhere
W: MakeTypeWitness<Arg = T>,
T: ?Sized,
impl<T, W> HasTypeWitness<W> for Twhere
W: MakeTypeWitness<Arg = T>,
T: ?Sized,
Source§impl<T> Identity for Twhere
T: ?Sized,
impl<T> Identity for Twhere
T: ?Sized,
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