fn should_share_session(
        &self,
        device: &Device,
        outbound_session: Option<&OutboundGroupSession>,
    ) -> Result<(), KeyshareDecision> {
        if device.user_id() == self.user_id() {
            if device.trust_state() {
                Ok(())
            } else {
                Err(KeyshareDecision::UntrustedDevice)
            }
        } else if let Some(outbound) = outbound_session {
            if outbound.is_shared_with(device.user_id(), device.device_id()) {
                Ok(())
            } else {
                Err(KeyshareDecision::OutboundSessionNotShared)
            }
        } else {
            Err(KeyshareDecision::MissingOutboundSession)
        }
    }
/// Check if it's ok to share a session with the given device.
///
/// The logic for this currently is as follows:
///
/// * Share any session with our own devices as long as they are trusted.
///
/// * Share with devices of other users only sessions that were meant to be
/// shared with them in the first place, in other words if an outbound
/// session still exists and the session was shared with that user/device
/// pair.
///
/// # Arguments
///
/// * `device` - The device that is requesting a session from us.
///
/// * `outbound_session` - If one still exists, the matching outbound
/// session that was used to create the inbound session that is being
/// requested.
Check if it's ok to share a session with the given device.
The logic for this currently is as follows.

Share any session with our own devices as long as they are trusted.

Share with devices of other users only sessions that were meant to be
shared with them in the first place, in other words if an outbound
session still exists and the session was shared with that user/device
pair.
Check if it ' s ok to share a session with the given device . The logic for this currently is as follows . Share any session with our own devices as long as they are trusted . Share with devices of other users only sessions that were meant to be shared with them in the first place in other words if an outbound session still exists and the session was shared with that user / device pair .
fn should_share_session(
        &self,
        device: &Device,
        outbound_session: Option<&OutboundGroupSession>,
    ) -> Result<(), KeyshareDecision> {
        if device.user_id() == self.user_id() {
            if device.trust_state() {
                Ok(())
            } else {
                Err(KeyshareDecision::UntrustedDevice)
            }
        } else if let Some(outbound) = outbound_session {
            if outbound.is_shared_with(device.user_id(), device.device_id()) {
                Ok(())
            } else {
                Err(KeyshareDecision::OutboundSessionNotShared)
            }
        } else {
            Err(KeyshareDecision::MissingOutboundSession)
        }
    }
fn should_share_session ( & self , device : & Device , outbound_session : Option < & OutboundGroupSession > , ) -> Result < ( ) , KeyshareDecision > { if device . user_id ( ) == self . user_id ( ) { if device . trust_state ( ) { Ok ( ( ) ) } else { Err ( KeyshareDecision :: UntrustedDevice ) } } else if let Some ( outbound ) = outbound_session { if outbound . is_shared_with ( device . user_id ( ) , device . device_id ( ) ) { Ok ( ( ) ) } else { Err ( KeyshareDecision :: OutboundSessionNotShared ) } } else { Err ( KeyshareDecision :: MissingOutboundSession ) } }
Check if it's ok to share a session with the given device.
Check if it ' s ok to share a session with the given device .
&self
device
&Device
outbound_session
Option<&OutboundGroupSession>
&self
device
&Device
outbound_session
Option<&OutboundGroupSession>