Struct conciliator::spin::Message
source · pub struct Message<'s> { /* private fields */ }
Expand description
Special Buffer
that sets the Spinner
message when dropped
Make sure that the Buffer
does not contain any newlines and that it is short enough to fit onto a single line.
If you don’t, the output will get messed up, and the user might not be able to read all of it (since some parts might get overwritten).
There’s no (easy) way to guarantee this doesn’t happen, the user can resize their terminal however they see fit, at any point.
In the future, there may be support for automatically truncating messages that are too long to fit into a single line, but currently there is not (it’s quite a bit more complicated than just checking the length of the Buffer
).
So, for the time being, just make sure that, together with the width of the animation (+3 for the brackets), the total stays well under the 80 columns rule.
Implementations§
Methods from Deref<Target = Buffer>§
sourcepub fn push_inline<T: Inline>(&mut self, thing: &T) -> &mut Self
pub fn push_inline<T: Inline>(&mut self, thing: &T) -> &mut Self
Append thing
onto the buffer using the Inline
trait
sourcepub fn push<M, T: Pushable<M>>(&mut self, thing: T) -> &mut Self
pub fn push<M, T: Pushable<M>>(&mut self, thing: T) -> &mut Self
Append thing
onto the buffer using either Inline
or Display
, doesn’t work if both are implemented for T
Pushable
is blanket-implemented for both Inline
and Display
types.
This would normally not be possible, because both blanket implementations could apply to the same type, thereby causing a conflict (Rust does not have any specialization or way to express where T: NOT Trait
).
So instead, this uses a trick that relies on a “marker type” being inferred.
This workaround is described in detail on Pushable
, but in short:
Pushable
has a type parameterM
(i.e.trait Pushable<M>
) that is not used except to make distinct implementations possible for the same typeimpl<T: Display> Pushable<marker::AsDisplay> for T
impl<T: Inline> Pushable<marker::AsInline> for T
push
is implemented for anyT: Pushable<M>
with anyM
- when there is only one applicable implementation, the marker type
M
can be inferred and won’t need to be specified - Surprisingly, it just works!
If, however, there are multiple applicable implementations (i.e. for a type implements Inline
and Display
), the type cannot be inferred: type annotations needed
.
In this case, it is easier to just use the more specific function instead of bothering with the type annotations.
(For the time being, the marker types are private, so type annotations are also impossible.)
use conciliator::{Conciliator, Wrap};
let con = conciliator::init();
con.line(..)
.push("Test") // &str,
.push(123) // i32 and
.push(' ') // char all implement Display
.push(Wrap::Alpha(":^)")); // Wrap implements Inline
Trait Implementations§
source§impl<'s> EmitEscapes for Message<'s>
impl<'s> EmitEscapes for Message<'s>
source§fn escapes_recognized(&self) -> bool
fn escapes_recognized(&self) -> bool
true
, escape codes will be emitted. Read moresource§fn set_color(&mut self, color: ColorCode) -> IoResult<()>
fn set_color(&mut self, color: ColorCode) -> IoResult<()>
\x1B[3???m
)source§impl<'s> Write for Message<'s>
impl<'s> Write for Message<'s>
source§fn write(&mut self, buf: &[u8]) -> IoResult<usize>
fn write(&mut self, buf: &[u8]) -> IoResult<usize>
source§fn flush(&mut self) -> IoResult<()>
fn flush(&mut self) -> IoResult<()>
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
)Auto Trait Implementations§
impl<'s> !RefUnwindSafe for Message<'s>
impl<'s> Send for Message<'s>
impl<'s> Sync for Message<'s>
impl<'s> Unpin for Message<'s>
impl<'s> !UnwindSafe for Message<'s>
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> Paint for Twhere
T: EmitEscapes,
impl<T> Paint for Twhere
T: EmitEscapes,
source§fn push_plain<T: Display + ?Sized>(&mut self, thing: &T) -> &mut Self
fn push_plain<T: Display + ?Sized>(&mut self, thing: &T) -> &mut Self
thing
onto the buffer using the Display
trait (plain uncolored text)source§fn push_bold<T: Display + ?Sized>(&mut self, thing: &T) -> &mut Self
fn push_bold<T: Display + ?Sized>(&mut self, thing: &T) -> &mut Self
thing
onto the buffer using the Display
trait (plain uncolored text but in bold)source§fn push_with_color_bold<T: Display + ?Sized>(
&mut self,
color: Color,
thing: &T
) -> &mut Self
fn push_with_color_bold<T: Display + ?Sized>( &mut self, color: Color, thing: &T ) -> &mut Self
push_with_color
but boldsource§fn push_with_any_color<T: Display + ?Sized>(
&mut self,
color: ColorCode,
thing: &T
) -> &mut Self
fn push_with_any_color<T: Display + ?Sized>( &mut self, color: ColorCode, thing: &T ) -> &mut Self
source§fn push_with_any_color_bold<T: Display + ?Sized>(
&mut self,
color: ColorCode,
thing: &T
) -> &mut Self
fn push_with_any_color_bold<T: Display + ?Sized>( &mut self, color: ColorCode, thing: &T ) -> &mut Self
push_with_any_color
but bold