Struct basic_text::TextDuplexer [−][src]
pub struct TextDuplexer<Inner: HalfDuplex + ReadStr + WriteStr> { /* fields omitted */ }
Expand description
A HalfDuplex
implementation which translates from an input HalfDuplex
implementation producing an arbitrary byte sequence into a valid Basic Text
stream.
Implementations
Construct a new instance of TextDuplexer
wrapping inner
, which can be
anything that implements HalfDuplex
.
Like new
, but writes a U+FEFF (BOM) to the beginning of the output
stream for compatibility with consumers that require that to determine
the text encoding.
Like new
, but enables CRLF output mode, which translates “\n” to
“\r\n” for compatibility with consumers that need that.
Note: This is not often needed; even on Windows these days most things are ok with plain ‘\n’ line endings, including Windows Notepad. The main notable things that really need them are IETF RFCs, for example RFC-5198.
Like new
, but replaces U+85 (NEL) with U+A instead of U+20.
Like new
, but replaces U+2028 (LS) and U+2029 (PS) with U+A instead
of U+20.
impl<Inner: HalfDuplex + ReadStr + ReadLayered + ReadStrLayered + WriteStr + WriteLayered> TextDuplexer<Inner>
impl<Inner: HalfDuplex + ReadStr + ReadLayered + ReadStrLayered + WriteStr + WriteLayered> TextDuplexer<Inner>
Like from_utf8
, but writes a U+FEFF (BOM) to the beginning of the output
stream for compatibility with consumers that require that to determine
the text encoding.
Like from_utf8
, but enables CRLF output mode, which translates “\n” to
“\r\n” for compatibility with consumers that need that.
Note: This is not often needed; even on Windows these days most things are ok with plain ‘\n’ line endings, including Windows Notepad. The main notable things that really need them are IETF RFCs, for example RFC-5198.
Like from_utf8
, but replaces U+85 (NEL) with U+A instead of U+20.
Like from_utf8
, but replaces U+2028 (LS) and U+2029 (PS) with U+A
instead of U+20.
Flush and close the underlying stream and return the underlying stream object.
Return the underlying stream object.
Trait Implementations
Borrows the file descriptor. Read more
A suggested size, in bytes, for buffering for performance.
Pull some bytes from this source into the specified buffer, returning how many bytes were read. Read more
Read all bytes until EOF in this source, placing them into buf
. Read more
Read all bytes until EOF in this source, appending them to buf
. Read more
Like read
, except that it reads into a slice of buffers. Read more
can_vector
)Determines if this Read
er has an efficient read_vectored
implementation. Read more
read_initializer
)Determines if this Read
er can work with buffers of uninitialized
memory. Read more
Read the exact number of bytes required to fill buf
. Read more
Creates a “by reference” adaptor for this instance of Read
. Read more
Creates an adaptor which will chain this stream with another. Read more
Like Read::read
, but also returns a Status
.
Some streams require a buffer of at least a certain size.
Like Read::read_vectored
, but also returns a Status
.
Like read
but produces the result in a str
. Be sure to check the
size
field of the return value to see how many bytes were written. Read more
Like read_exact
but produces the result in a str
.
impl<Inner: HalfDuplexLayered + ReadStrLayered + WriteStr> ReadStrLayered for TextDuplexer<Inner>
impl<Inner: HalfDuplexLayered + ReadStrLayered + WriteStr> ReadStrLayered for TextDuplexer<Inner>
Like read_with_status
but produces the result in a str
. Be sure to
check the return value to see how many bytes were written. Read more
Like read_str
but for reading Basic Text content. Note that the
resulting data may not be a Basic Text string, as it may be eg. a
portion of a stream that starts with a non-starter. Read more
Like read_exact_str
but for reading Basic Text content. As with
read_text
, the resulting string may not be a Basic Text string. Read more
Like read_to_string
, but reads into a TextString
.
impl<Inner: HalfDuplexLayered + ReadStrLayered + WriteStr> ReadTextLayered for TextDuplexer<Inner>
impl<Inner: HalfDuplexLayered + ReadStrLayered + WriteStr> ReadTextLayered for TextDuplexer<Inner>
Like read_str_with_status
but for reading Basic Text data. Note that
the resulting data may not be a Basic Text string, as it may be eg. a
portion of a stream that starts with a non-starter. Read more
Like read_exact_str_using_status
but for reading Basic Text content.
As with read_text
, the resulting string may not be a Basic Text
string. Read more
Write a buffer into this writer, returning how many bytes were written. Read more
Flush this output stream, ensuring that all intermediately buffered contents reach their destination. Read more
can_vector
)Determines if this Write
r has an efficient write_vectored
implementation. Read more
write_all_vectored
)Attempts to write multiple buffers into this writer. Read more
Attempts to write an entire buffer into this writer. Read more
Writes a formatted string into this writer, returning any error encountered. Read more
impl<Inner: HalfDuplexLayered + ReadStrLayered + WriteStr> WriteLayered for TextDuplexer<Inner>
impl<Inner: HalfDuplexLayered + ReadStrLayered + WriteStr> WriteLayered for TextDuplexer<Inner>
Like WriteStr::write_str
but writes from a TextSubstr
.
Like WriteStr::write_str
but writes from a TextStr
.
Auto Trait Implementations
impl<Inner> RefUnwindSafe for TextDuplexer<Inner> where
Inner: RefUnwindSafe,
impl<Inner> Send for TextDuplexer<Inner> where
Inner: Send,
impl<Inner> Sync for TextDuplexer<Inner> where
Inner: Sync,
impl<Inner> Unpin for TextDuplexer<Inner> where
Inner: Unpin,
impl<Inner> UnwindSafe for TextDuplexer<Inner> where
Inner: UnwindSafe,
Blanket Implementations
Borrows the reference. Read more
pub fn as_filelike_view<Target>(&self) -> FilelikeView<'_, Target> where
Target: FromFilelike + IntoFilelike,
pub fn as_filelike_view<Target>(&self) -> FilelikeView<'_, Target> where
Target: FromFilelike + IntoFilelike,
Return a borrowing view of a resource which dereferences to a &Target
or &mut Target
. Read more
Extracts the grip.
Extracts the raw grip.
Borrows the reference.
pub fn as_socketlike_view<Target>(&self) -> FilelikeView<'_, Target> where
Target: FromSocketlike + IntoSocketlike,
pub fn as_socketlike_view<Target>(&self) -> FilelikeView<'_, Target> where
Target: FromSocketlike + IntoSocketlike,
Return a borrowing view of a resource which dereferences to a &Target
or &mut Target
. Read more
Mutably borrows from an owned value. Read more