Struct sailfish::runtime::Buffer

source ·
pub struct Buffer { /* private fields */ }
Expand description

Buffer for rendered contents

This struct is quite simular to String, but some methods are re-implemented for faster buffering.

Implementations§

source§

impl Buffer

source

pub const fn new() -> Buffer

Create an empty buffer

source

pub fn with_capacity(n: usize) -> Buffer

Create a empty buffer with a particular capacity

source

pub fn as_str(&self) -> &str

Extracts a string slice containing the entire buffer

source

pub fn as_mut_ptr(&self) -> *mut u8

Returns an unsafe mutable pointer to the inner data

source

pub fn len(&self) -> usize

Returns the length of this buffer in bytes

source

pub fn capacity(&self) -> usize

Returns this buffer’s capacity in bytes

source

pub unsafe fn advance(&mut self, additional: usize)

Increase the length of buffer by additional bytes

Safety
  • additional must be less than or equal to capacity() - len()
  • The elements at old_len..old_len + additional must be initialized
source

pub fn is_empty(&self) -> bool

Returns true if this buffer has a length of zero, and false otherwise

source

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

Same as String::reserve

Panics

This method panics if size overflows isize::MAX.

source

pub fn into_string(self) -> String

Converts a Buffer into a String without copy/realloc operation.

source

pub fn push_str(&mut self, data: &str)

Appends a given string slice onto the end of this buffer

source

pub fn push(&mut self, data: char)

Appends the given char to the end of this buffer

Trait Implementations§

source§

impl Add<&str> for Buffer

§

type Output = Buffer

The resulting type after applying the + operator.
source§

fn add(self, other: &str) -> Buffer

Performs the + operation. Read more
source§

impl AddAssign<&str> for Buffer

source§

fn add_assign(&mut self, other: &str)

Performs the += operation. Read more
source§

impl Clone for Buffer

source§

fn clone(&self) -> Self

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for Buffer

source§

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

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

impl Default for Buffer

source§

fn default() -> Buffer

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

impl Drop for Buffer

source§

fn drop(&mut self)

Executes the destructor for this type. Read more
source§

impl From<&str> for Buffer

source§

fn from(other: &str) -> Buffer

Converts to this type from the input type.
source§

impl From<String> for Buffer

source§

fn from(other: String) -> Buffer

Shrink the data and pass raw pointer directory to buffer

This operation is O(1)

source§

impl Write for Buffer

source§

fn write_str(&mut self, s: &str) -> Result

Writes a string slice into this writer, returning whether the write succeeded. Read more
1.1.0 · source§

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

Writes a char into this writer, returning whether the write succeeded. Read more
1.0.0 · source§

fn write_fmt(&mut self, args: Arguments<'_>) -> Result<(), Error>

Glue for usage of the write! macro with implementors of this trait. Read more
source§

impl Send for Buffer

source§

impl Sync for Buffer

Auto Trait Implementations§

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> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. 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.