pub(crate) struct PersistentTransportState {
transport_cipher: TransportCipher,
send_key: SymmetricKey,
receive_key: SymmetricKey,
send_nonce: u64,
receive_nonce: u64,
last_handshake_time: u64,
}Fields§
§transport_cipher: TransportCipher§send_key: SymmetricKey§receive_key: SymmetricKey§send_nonce: u64§receive_nonce: u64§last_handshake_time: u64Implementations§
Source§impl PersistentTransportState
impl PersistentTransportState
Sourcepub(crate) fn new(
send_key: SymmetricKey,
receive_key: SymmetricKey,
transport_cipher: TransportCipher,
) -> Self
pub(crate) fn new( send_key: SymmetricKey, receive_key: SymmetricKey, transport_cipher: TransportCipher, ) -> Self
Create a new transport state with the given keys and cipher.
pub(crate) fn should_rehandshake(&self, rehandshake_interval_secs: u64) -> bool
pub(crate) fn is_older_than( &self, now_epoch_secs: u64, max_age_secs: u64, ) -> bool
Source§impl PersistentTransportState
impl PersistentTransportState
Sourcepub(crate) fn send(&mut self, payload: Payload) -> Result<TransportFrame, ()>
pub(crate) fn send(&mut self, payload: Payload) -> Result<TransportFrame, ()>
Encrypts the message, mutates the state and returns the transport frame to be sent over IPC.
Sourcepub(crate) fn receive(
&mut self,
transport_frame: &TransportFrame,
) -> Result<Payload, ReceiveError>
pub(crate) fn receive( &mut self, transport_frame: &TransportFrame, ) -> Result<Payload, ReceiveError>
Decrypts the transport frame, mutates the state and returns the plaintext message.
fn encrypt(&self, key: &SymmetricKey, nonce: u64, payload: &Payload) -> Vec<u8> ⓘ
fn try_decrypt( &self, key: &SymmetricKey, transport_message: &TransportFrame, ) -> Result<Vec<u8>, ()>
Trait Implementations§
Source§impl Clone for PersistentTransportState
impl Clone for PersistentTransportState
Source§fn clone(&self) -> PersistentTransportState
fn clone(&self) -> PersistentTransportState
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for PersistentTransportState
impl Debug for PersistentTransportState
Source§impl<'de> Deserialize<'de> for PersistentTransportState
impl<'de> Deserialize<'de> for PersistentTransportState
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl From<&mut HandshakeInitiator> for PersistentTransportState
impl From<&mut HandshakeInitiator> for PersistentTransportState
Source§fn from(initiator: &mut HandshakeInitiator) -> Self
fn from(initiator: &mut HandshakeInitiator) -> Self
Converts to this type from the input type.
Source§impl From<&mut HandshakeResponder> for PersistentTransportState
impl From<&mut HandshakeResponder> for PersistentTransportState
Source§fn from(responder: &mut HandshakeResponder) -> Self
fn from(responder: &mut HandshakeResponder) -> Self
Converts to this type from the input type.
Auto Trait Implementations§
impl Freeze for PersistentTransportState
impl RefUnwindSafe for PersistentTransportState
impl Send for PersistentTransportState
impl Sync for PersistentTransportState
impl Unpin for PersistentTransportState
impl UnsafeUnpin for PersistentTransportState
impl UnwindSafe for PersistentTransportState
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
Mutably borrows from an owned value. Read more