Struct gix_transport::client::RequestWriter
source · pub struct RequestWriter<'a> { /* private fields */ }
blocking-client
only.Expand description
A Write
implementation optimized for writing packet lines.
A type implementing Write
for packet lines, which when done can be transformed into a Read
for
obtaining the response.
Implementations§
source§impl<'a> RequestWriter<'a>
impl<'a> RequestWriter<'a>
methods with bonds to IO
sourcepub fn new_from_bufread<W: Write + 'a>(
writer: W,
reader: Box<dyn ExtendedBufRead<'a> + Unpin + 'a>,
write_mode: WriteMode,
on_into_read: MessageKind,
trace: bool,
) -> Self
pub fn new_from_bufread<W: Write + 'a>( writer: W, reader: Box<dyn ExtendedBufRead<'a> + Unpin + 'a>, write_mode: WriteMode, on_into_read: MessageKind, trace: bool, ) -> Self
Create a new instance from a writer
(commonly a socket), a reader
into which to transform once the
writes are finished, along with configuration for the write_mode
and information about which message to write
when this instance is converted into a reader
to read the request’s response.
If trace
is true, gix_trace
will be used on every written message or data.
sourcepub fn write_message(&mut self, message: MessageKind) -> Result<()>
pub fn write_message(&mut self, message: MessageKind) -> Result<()>
Write the given message as packet line.
sourcepub fn into_read(self) -> Result<Box<dyn ExtendedBufRead<'a> + Unpin + 'a>>
pub fn into_read(self) -> Result<Box<dyn ExtendedBufRead<'a> + Unpin + 'a>>
Discard the ability to write and turn this instance into the reader for obtaining the other side’s response.
Doing so will also write the message type this instance was initialized with.
sourcepub fn into_parts(
self,
) -> (Box<dyn Write + 'a>, Box<dyn ExtendedBufRead<'a> + Unpin + 'a>)
pub fn into_parts( self, ) -> (Box<dyn Write + 'a>, Box<dyn ExtendedBufRead<'a> + Unpin + 'a>)
Dissolve this instance into its write and read handles without any message-writing side-effect as in RequestWriter::into_read()
.
Furthermore, the writer will not encode everything it writes as packetlines, but write everything verbatim into the underlying channel.
§Note
It’s of utmost importance to drop the request writer before reading the response as these might be inter-dependent, depending on the underlying transport mechanism. Failure to do so may result in a deadlock depending on how the write and read mechanism is implemented.
Trait Implementations§
source§impl<'a> Write for RequestWriter<'a>
impl<'a> Write for RequestWriter<'a>
source§fn write(&mut self, buf: &[u8]) -> Result<usize>
fn write(&mut self, buf: &[u8]) -> Result<usize>
source§fn flush(&mut self) -> Result<()>
fn flush(&mut self) -> Result<()>
source§fn is_write_vectored(&self) -> bool
fn is_write_vectored(&self) -> bool
can_vector
)1.0.0 · source§fn write_all(&mut self, buf: &[u8]) -> Result<(), Error>
fn write_all(&mut self, buf: &[u8]) -> Result<(), Error>
source§fn write_all_vectored(&mut self, bufs: &mut [IoSlice<'_>]) -> Result<(), Error>
fn write_all_vectored(&mut self, bufs: &mut [IoSlice<'_>]) -> Result<(), Error>
write_all_vectored
)