Struct termimad::CropWriter

source ·
pub struct CropWriter<'w, W>
where W: Write,
{ pub w: &'w mut W, pub allowed: usize, pub tab_replacement: &'static str, }
Expand description

wrap a writer to ensure that at most allowed columns are written.

Fields§

§w: &'w mut W§allowed: usize

number of screen columns which may be covered

§tab_replacement: &'static str

the string replacing a tabulation

Implementations§

source§

impl<'w, W> CropWriter<'w, W>
where W: Write,

source

pub fn new(w: &'w mut W, limit: usize) -> Self

source

pub const fn is_full(&self) -> bool

source

pub fn cropped_str<'a>(&self, s: &'a str) -> (Cow<'a, str>, usize)

return a tuple containing a string containing either the given &str or the part fitting the remaining width, and the width of this string)

source

pub fn queue_unstyled_str(&mut self, s: &str) -> Result<(), Error>

source

pub fn queue_str(&mut self, cs: &CompoundStyle, s: &str) -> Result<(), Error>

source

pub fn queue_char(&mut self, cs: &CompoundStyle, c: char) -> Result<(), Error>

source

pub fn queue_unstyled_char(&mut self, c: char) -> Result<(), Error>

source

pub fn queue_unstyled_g_string(&mut self, s: String) -> Result<(), Error>

a “g_string” is a “gentle” one: each char takes one column on screen. This function must thus not be used for unknown strings.

source

pub fn queue_g_string( &mut self, cs: &CompoundStyle, s: String ) -> Result<(), Error>

a “g_string” is a “gentle” one: each char takes one column on screen. This function must thus not be used for unknown strings.

source

pub fn queue_fg(&mut self, cs: &CompoundStyle) -> Result<(), Error>

source

pub fn queue_bg(&mut self, cs: &CompoundStyle) -> Result<(), Error>

source

pub fn fill( &mut self, cs: &CompoundStyle, filling: &'static Filling ) -> Result<(), Error>

source

pub fn fill_unstyled(&mut self, filling: &'static Filling) -> Result<(), Error>

source

pub fn fill_with_space(&mut self, cs: &CompoundStyle) -> Result<(), Error>

source

pub fn repeat( &mut self, cs: &CompoundStyle, filling: &'static Filling, len: usize ) -> Result<(), Error>

source

pub fn repeat_unstyled( &mut self, filling: &'static Filling, len: usize ) -> Result<(), Error>

Auto Trait Implementations§

§

impl<'w, W> Freeze for CropWriter<'w, W>

§

impl<'w, W> RefUnwindSafe for CropWriter<'w, W>
where W: RefUnwindSafe,

§

impl<'w, W> Send for CropWriter<'w, W>
where W: Send,

§

impl<'w, W> Sync for CropWriter<'w, W>
where W: Sync,

§

impl<'w, W> Unpin for CropWriter<'w, W>

§

impl<'w, W> !UnwindSafe for CropWriter<'w, W>

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> Pointable for T

source§

const ALIGN: usize = _

The alignment of pointer.
§

type Init = T

The type for initializers.
source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.