pub trait Open {
type W: Open<Error = Self::Error>;
type Error: Display + Debug;
// Required methods
fn writer(&mut self) -> &mut Self::W;
fn write_fmt(&mut self, arg: Arguments<'_>) -> Result<(), Self::Error>;
// Provided methods
fn ref_open<O: Opener>(
&mut self,
e: O,
) -> Result<WriteScope<O::Close, &mut Self::W>, <Self::W as Open>::Error> { ... }
fn open_scope<O: Opener>(
&mut self,
e: O,
f: impl FnOnce(&mut WriteScope<O::Close, &mut Self::W>) -> Result<(), <Self::W as Open>::Error>,
) -> Result<(), <Self::W as Open>::Error> { ... }
fn open<O: Opener>(
self,
e: O,
) -> Result<WriteScope<O::Close, Self>, <Self::W as Open>::Error>
where Self: Sized { ... }
fn text(&mut self, d: impl Display) -> Result<(), <Self::W as Open>::Error> { ... }
}Expand description
The work-horse of this crate.
This is a kind of hybrid between DerefMut where Target: Write, and Write itself, with added methods with default implementations to open scopes. This is done in one big traits rather than with super traits to avoid issues with the orphan rule.
Required Associated Types§
Required Methods§
Provided Methods§
Sourcefn ref_open<O: Opener>(
&mut self,
e: O,
) -> Result<WriteScope<O::Close, &mut Self::W>, <Self::W as Open>::Error>
fn ref_open<O: Opener>( &mut self, e: O, ) -> Result<WriteScope<O::Close, &mut Self::W>, <Self::W as Open>::Error>
Open a new scope, taking a reference to self
Sourcefn open_scope<O: Opener>(
&mut self,
e: O,
f: impl FnOnce(&mut WriteScope<O::Close, &mut Self::W>) -> Result<(), <Self::W as Open>::Error>,
) -> Result<(), <Self::W as Open>::Error>
fn open_scope<O: Opener>( &mut self, e: O, f: impl FnOnce(&mut WriteScope<O::Close, &mut Self::W>) -> Result<(), <Self::W as Open>::Error>, ) -> Result<(), <Self::W as Open>::Error>
Open a scope and pass it as argument to the provided closure, closing it at the closures end
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.