Skip to main content

Writer

Struct Writer 

Source
pub struct Writer {
    pub buffer: Vec<u8>,
    pub id: u32,
    pub extra: i64,
}
Expand description

growable utf-8 buffer

Fields§

§buffer: Vec<u8>

the written bytes

§id: u32

unique id of the content of the writer: it changes when the writer is reset

§extra: i64

number of bytes written minus the number of UTF-16 code units of the written strings

Implementations§

Source§

impl Writer

Source

pub fn new(capacity: usize) -> Self

Source

pub fn length(&self) -> usize

number of bytes written

Source

pub fn write(&mut self, str: &str)

write a string

Source

pub fn write_byte(&mut self, code: u8)

write an ascii character

Source

pub fn copy(&mut self, start: usize, end: usize, extra: i64)

copy bytes already written to the end of the buffer

Source

pub fn code_length(&self) -> usize

length of the written css once decoded, in UTF-16 code units

Source

pub fn reset(&mut self)

drop the written bytes: the writer is reused. it gets a new id

Source

pub fn truncate(&mut self, length: usize, extra: i64)

drop the bytes written after a position

Source

pub fn last_byte(&self) -> i32

last byte written, -1 when nothing is written

Source

pub fn reserve(&mut self, size: usize)

make room for size more bytes

Source

pub fn bytes(&self) -> &[u8] ⓘ

the written bytes

Source

pub fn as_str(&self) -> &str

the written css

Source

pub fn into_bytes(self) -> Vec<u8> ⓘ

take the written bytes

Trait Implementations§

Source§

impl Debug for Writer

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Writer

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl Forget for Writer

§

impl Freeze for Writer

§

impl Move for Writer

§

impl RefUnwindSafe for Writer

§

impl Send for Writer

§

impl Sync for Writer

§

impl Unpin for Writer

§

impl UnsafeUnpin for Writer

§

impl UnwindSafe for Writer

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> Same for T

Source§

type Output = T

Should always be Self
Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

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

Source§

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.