Struct bevy_internal::log::tracing_subscriber::fmt::format::Writer
source · pub struct Writer<'writer> { /* private fields */ }
Expand description
A writer to which formatted representations of spans and events are written.
This type is provided as input to the FormatEvent::format_event
and
FormatFields::format_fields
methods, which will write formatted
representations of Event
s and fields to the Writer
.
This type implements the std::fmt::Write
trait, allowing it to be used
with any function that takes an instance of std::fmt::Write
.
Additionally, it can be used with the standard library’s std::write!
and
std::writeln!
macros.
Additionally, a Writer
may expose additional tracing
-specific
information to the formatter implementation.
Implementations§
source§impl<'writer> Writer<'writer>
impl<'writer> Writer<'writer>
sourcepub fn new(writer: &'writer mut impl Write) -> Writer<'writer>
pub fn new(writer: &'writer mut impl Write) -> Writer<'writer>
Create a new Writer
from any type that implements fmt::Write
.
The returned Writer
value may be passed as an argument to methods
such as Format::format_event
. Since constructing a Writer
mutably borrows the underlying fmt::Write
instance, that value may
be accessed again once the Writer
is dropped. For example, if the
value implementing fmt::Write
is a String
, it will contain
the formatted output of Format::format_event
, which may then be
used for other purposes.
sourcepub fn by_ref(&mut self) -> Writer<'_>
pub fn by_ref(&mut self) -> Writer<'_>
Return a new Writer
that mutably borrows self
.
This can be used to temporarily borrow a Writer
to pass a new Writer
to a function that takes a Writer
by value, allowing the original writer
to still be used once that function returns.
sourcepub fn write_str(&mut self, s: &str) -> Result<(), Error>
pub fn write_str(&mut self, s: &str) -> Result<(), Error>
Writes a string slice into this Writer
, returning whether the write succeeded.
This method can only succeed if the entire string slice was successfully written, and this method will not return until all data has been written or an error occurs.
This is identical to calling the write_str
method from the Writer
’s
std::fmt::Write
implementation. However, it is also provided as an
inherent method, so that Writer
s can be used without needing to import the
std::fmt::Write
trait.
§Errors
This function will return an instance of std::fmt::Error
on error.
sourcepub fn write_char(&mut self, c: char) -> Result<(), Error>
pub fn write_char(&mut self, c: char) -> Result<(), Error>
Writes a char
into this writer, returning whether the write succeeded.
A single char
may be encoded as more than one byte.
This method can only succeed if the entire byte sequence was successfully
written, and this method will not return until all data has been
written or an error occurs.
This is identical to calling the write_char
method from the Writer
’s
std::fmt::Write
implementation. However, it is also provided as an
inherent method, so that Writer
s can be used without needing to import the
std::fmt::Write
trait.
§Errors
This function will return an instance of std::fmt::Error
on error.
sourcepub fn write_fmt(&mut self, args: Arguments<'_>) -> Result<(), Error>
pub fn write_fmt(&mut self, args: Arguments<'_>) -> Result<(), Error>
Glue for usage of the write!
macro with Writer
s.
This method should generally not be invoked manually, but rather through
the write!
macro itself.
This is identical to calling the write_fmt
method from the Writer
’s
std::fmt::Write
implementation. However, it is also provided as an
inherent method, so that Writer
s can be used with the [write!
macro]
without needing to import the
std::fmt::Write
trait.
sourcepub fn has_ansi_escapes(&self) -> bool
pub fn has_ansi_escapes(&self) -> bool
Returns true
if ANSI escape codes may be used to add colors
and other formatting when writing to this Writer
.
If this returns false
, formatters should not emit ANSI escape codes.
Trait Implementations§
source§impl<'a> MakeVisitor<Writer<'a>> for DefaultFields
impl<'a> MakeVisitor<Writer<'a>> for DefaultFields
§type Visitor = DefaultVisitor<'a>
type Visitor = DefaultVisitor<'a>
MakeVisitor
.source§fn make_visitor(
&self,
target: Writer<'a>
) -> <DefaultFields as MakeVisitor<Writer<'a>>>::Visitor
fn make_visitor( &self, target: Writer<'a> ) -> <DefaultFields as MakeVisitor<Writer<'a>>>::Visitor
target
.source§impl<'a, F> MakeVisitor<Writer<'a>> for FieldFn<F>
impl<'a, F> MakeVisitor<Writer<'a>> for FieldFn<F>
§type Visitor = FieldFnVisitor<'a, F>
type Visitor = FieldFnVisitor<'a, F>
MakeVisitor
.source§fn make_visitor(
&self,
writer: Writer<'a>
) -> <FieldFn<F> as MakeVisitor<Writer<'a>>>::Visitor
fn make_visitor( &self, writer: Writer<'a> ) -> <FieldFn<F> as MakeVisitor<Writer<'a>>>::Visitor
target
.source§impl<'a> MakeVisitor<Writer<'a>> for PrettyFields
impl<'a> MakeVisitor<Writer<'a>> for PrettyFields
§type Visitor = PrettyVisitor<'a>
type Visitor = PrettyVisitor<'a>
MakeVisitor
.source§fn make_visitor(
&self,
target: Writer<'a>
) -> <PrettyFields as MakeVisitor<Writer<'a>>>::Visitor
fn make_visitor( &self, target: Writer<'a> ) -> <PrettyFields as MakeVisitor<Writer<'a>>>::Visitor
target
.Auto Trait Implementations§
impl<'writer> Freeze for Writer<'writer>
impl<'writer> !RefUnwindSafe for Writer<'writer>
impl<'writer> !Send for Writer<'writer>
impl<'writer> !Sync for Writer<'writer>
impl<'writer> Unpin for Writer<'writer>
impl<'writer> !UnwindSafe for Writer<'writer>
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
source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
. Box<dyn Any>
can
then be further downcast
into Box<ConcreteType>
where ConcreteType
implements Trait
.source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s.source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.