pub struct NegotiationWriter<W: AsyncWrite + Unpin> { /* private fields */ }Expand description
Writes length-prefixed negotiation frames to an AsyncWrite transport.
NegotiationWriter::write_frame writes a 4-byte big-endian length
prefix followed by the body, then flushes.
For server-side error responses, the body MUST be under 16 MiB
(MAX_CHUNK_LEN) so the high byte of the length prefix is 0x00 —
this is the wire-format invariant that makes the framing-disambiguation
trick sound (see ADR-052 §5). Self::write_frame does not enforce
this; callers building error responses with error_response_bytes are
well within the limit by construction.
Implementations§
Source§impl<W: AsyncWrite + Unpin> NegotiationWriter<W>
impl<W: AsyncWrite + Unpin> NegotiationWriter<W>
Sourcepub fn new(writer: W) -> Self
pub fn new(writer: W) -> Self
Wrap an AsyncWrite transport in a negotiation frame writer.
Sourcepub fn into_inner(self) -> W
pub fn into_inner(self) -> W
Consume the writer and return the underlying transport.
Sourcepub async fn write_frame(&mut self, body: &[u8]) -> Result<(), NegotiationError>
pub async fn write_frame(&mut self, body: &[u8]) -> Result<(), NegotiationError>
Write one length-prefixed frame: 4-byte BE length + body + flush.
Auto Trait Implementations§
impl<W> Freeze for NegotiationWriter<W>where
W: Freeze,
impl<W> RefUnwindSafe for NegotiationWriter<W>where
W: RefUnwindSafe,
impl<W> Send for NegotiationWriter<W>where
W: Send,
impl<W> Sync for NegotiationWriter<W>where
W: Sync,
impl<W> Unpin for NegotiationWriter<W>
impl<W> UnsafeUnpin for NegotiationWriter<W>where
W: UnsafeUnpin,
impl<W> UnwindSafe for NegotiationWriter<W>where
W: UnwindSafe,
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