pub struct SecureChannel {
pub peer_id: DeviceId,
pub established_at: SystemTime,
/* private fields */
}Expand description
Secure channel between two peers
Fields§
§peer_id: DeviceIdPeer identifier
established_at: SystemTimeWhen channel was established
Implementations§
Source§impl SecureChannel
impl SecureChannel
Sourcepub fn new(peer_id: DeviceId, key: SymmetricKey) -> SecureChannel
pub fn new(peer_id: DeviceId, key: SymmetricKey) -> SecureChannel
Create new secure channel
Sourcepub fn encrypt(&self, plaintext: &[u8]) -> Result<EncryptedData, SecurityError>
pub fn encrypt(&self, plaintext: &[u8]) -> Result<EncryptedData, SecurityError>
Encrypt message for peer
Sourcepub fn decrypt(
&self,
encrypted: &EncryptedData,
) -> Result<Vec<u8>, SecurityError>
pub fn decrypt( &self, encrypted: &EncryptedData, ) -> Result<Vec<u8>, SecurityError>
Decrypt message from peer
Trait Implementations§
Auto Trait Implementations§
impl Freeze for SecureChannel
impl RefUnwindSafe for SecureChannel
impl Send for SecureChannel
impl Sync for SecureChannel
impl Unpin for SecureChannel
impl UnsafeUnpin for SecureChannel
impl UnwindSafe for SecureChannel
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
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>
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 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>
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