pub struct FrameWriter;Expand description
Zero-copy frame writer — encrypts and writes in a single syscall
Implementations§
Source§impl FrameWriter
impl FrameWriter
Sourcepub const SPAWN_BLOCKING_THRESHOLD: usize
pub const SPAWN_BLOCKING_THRESHOLD: usize
Threshold size (bytes) above which we use tokio::task::spawn_blocking for encryption
Sourcepub async fn write_frame(
&self,
stream: &mut TcpStream,
session: &CryptoSession,
data: &[u8],
) -> Result<usize, FrameError>
pub async fn write_frame( &self, stream: &mut TcpStream, session: &CryptoSession, data: &[u8], ) -> Result<usize, FrameError>
Write a single message as one or more frames: [len:4][encrypted_payload + tag:16]
If data exceeds MAX_FRAME_PAYLOAD, it is split into multiple frames. If total data exceeds SPAWN_BLOCKING_THRESHOLD, encryption is offloaded to spawn_blocking.
Sourcepub async fn write_frames_batch(
&self,
stream: &mut TcpStream,
session: &CryptoSession,
payloads: &[&[u8]],
) -> Result<usize, FrameError>
pub async fn write_frames_batch( &self, stream: &mut TcpStream, session: &CryptoSession, payloads: &[&[u8]], ) -> Result<usize, FrameError>
Write multiple frames in a batch (TCP write coalescing). Accumulates all frames into a single buffer → one write_all().
Source§impl FrameWriter
impl FrameWriter
pub async fn write_frame_padded( &self, stream: &mut TcpStream, session: &CryptoSession, data: &[u8], profile: PaddingProfile, ) -> Result<usize, FrameError>
Trait Implementations§
Auto Trait Implementations§
impl Freeze for FrameWriter
impl RefUnwindSafe for FrameWriter
impl Send for FrameWriter
impl Sync for FrameWriter
impl Unpin for FrameWriter
impl UnsafeUnpin for FrameWriter
impl UnwindSafe for FrameWriter
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