Struct basic_text::TextWriter [−][src]
pub struct TextWriter<Inner> { /* fields omitted */ }
Expand description
A WriteLayered
implementation which translates to an output
WriteLayered
producing a valid Basic Text stream from an arbitrary
byte sequence.
write
is not guaranteed to perform a single operation, because short
writes could produce invalid UTF-8, so write
will retry as needed.
Examples
use basic_text::TextWriter; use layered_io::WriteLayered; let mut output = TextWriter::new(std::io::stdout()); // write to `output` output.close().unwrap();
Implementations
Construct a new instance of TextWriter
wrapping inner
, which can be
anything that implements Write
.
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.
Construct a new instance of TextWriter
wrapping inner
, which
can be anything that implements WriteStr + WriteLayered
, such as a
Utf8Writer
.
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.
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.
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
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 TextWriter<Inner> where
Inner: RefUnwindSafe,
impl<Inner> Send for TextWriter<Inner> where
Inner: Send,
impl<Inner> Sync for TextWriter<Inner> where
Inner: Sync,
impl<Inner> Unpin for TextWriter<Inner> where
Inner: Unpin,
impl<Inner> UnwindSafe for TextWriter<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