pub struct SecureChannel<T> { /* private fields */ }Expand description
High-level blocking facade that combines Session, SyncIo, and TLV helpers.
This wrapper is intended for the common case where callers want:
- automatic session-aware control/rekey handling
- application-data TLV framing by default
- a simple send/receive application-data API
Implementations§
Source§impl<T: Read + Write> SecureChannel<T>
impl<T: Read + Write> SecureChannel<T>
Sourcepub fn from_active_session(io: T, session: Session) -> Result<Self, CoreError>
pub fn from_active_session(io: T, session: Session) -> Result<Self, CoreError>
Constructs a secure channel from an active session.
The session must already be in Active state with derived traffic keys.
Sourcepub fn with_app_stream_id(self, stream_id: u32) -> Self
pub fn with_app_stream_id(self, stream_id: u32) -> Self
Sets the default stream ID for application-data frames.
Sourcepub fn with_app_flags(self, flags: u8) -> Self
pub fn with_app_flags(self, flags: u8) -> Self
Sets the default plaintext frame flags for application-data frames.
Sourcepub fn session_mut(&mut self) -> &mut Session
pub fn session_mut(&mut self) -> &mut Session
Returns mutable reference to the underlying Session.
Sourcepub fn send_data(&mut self, plaintext: &[u8]) -> Result<(), CoreError>
pub fn send_data(&mut self, plaintext: &[u8]) -> Result<(), CoreError>
Sends application data in an APPLICATION_DATA TLV with session-aware rekey handling.
Sourcepub fn send_tlvs(&mut self, tlvs: &[Tlv]) -> Result<(), CoreError>
pub fn send_tlvs(&mut self, tlvs: &[Tlv]) -> Result<(), CoreError>
Sends explicit TLVs with session-aware rekey handling.
This bypasses APPLICATION_DATA convenience framing.
Sourcepub fn recv_application(&mut self) -> Result<Vec<u8>, CoreError>
pub fn recv_application(&mut self) -> Result<Vec<u8>, CoreError>
Receives the next application-data payload.
Control frames are handled automatically. The method loops internally until
it receives a non-control frame, then decodes TLVs and returns the first
APPLICATION_DATA value.
Sourcepub fn recv_tlvs(&mut self) -> Result<Vec<Tlv>, CoreError>
pub fn recv_tlvs(&mut self) -> Result<Vec<Tlv>, CoreError>
Receives the next non-control frame and returns decoded TLVs.
Sourcepub fn into_parts(self) -> (T, Session)
pub fn into_parts(self) -> (T, Session)
Consumes the wrapper and returns (io, session).