mirror of
https://github.com/tokio-rs/tokio.git
synced 2026-08-30 00:00:16 +02:00
util: expose FramedWrite/Framed::write_buffer/write_buffer_mut
This commit is contained in:
@@ -208,6 +208,16 @@ impl<T, U> Framed<T, U> {
|
|||||||
&mut self.inner.state.read.buffer
|
&mut self.inner.state.read.buffer
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Returns a reference to the write buffer.
|
||||||
|
pub fn write_buffer(&self) -> &BytesMut {
|
||||||
|
&self.inner.state.write.buffer
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Returns a mutable reference to the write buffer.
|
||||||
|
pub fn write_buffer_mut(&mut self) -> &mut BytesMut {
|
||||||
|
&mut self.inner.state.write.buffer
|
||||||
|
}
|
||||||
|
|
||||||
/// Consumes the `Framed`, returning its underlying I/O stream.
|
/// Consumes the `Framed`, returning its underlying I/O stream.
|
||||||
///
|
///
|
||||||
/// Note that care should be taken to not tamper with the underlying stream
|
/// Note that care should be taken to not tamper with the underlying stream
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ use crate::codec::framed_impl::{FramedImpl, WriteFrame};
|
|||||||
use tokio::io::AsyncWrite;
|
use tokio::io::AsyncWrite;
|
||||||
use tokio_stream::Stream;
|
use tokio_stream::Stream;
|
||||||
|
|
||||||
|
use bytes::BytesMut;
|
||||||
use futures_sink::Sink;
|
use futures_sink::Sink;
|
||||||
use pin_project_lite::pin_project;
|
use pin_project_lite::pin_project;
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
@@ -86,6 +87,16 @@ impl<T, E> FramedWrite<T, E> {
|
|||||||
pub fn encoder_mut(&mut self) -> &mut E {
|
pub fn encoder_mut(&mut self) -> &mut E {
|
||||||
&mut self.inner.codec
|
&mut self.inner.codec
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Returns a reference to the write buffer.
|
||||||
|
pub fn write_buffer(&self) -> &BytesMut {
|
||||||
|
&self.inner.state.buffer
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Returns a mutable reference to the write buffer.
|
||||||
|
pub fn write_buffer_mut(&mut self) -> &mut BytesMut {
|
||||||
|
&mut self.inner.state.buffer
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// This impl just defers to the underlying FramedImpl
|
// This impl just defers to the underlying FramedImpl
|
||||||
|
|||||||
Reference in New Issue
Block a user