Struct sval_buffer::TextBuf

source ·
pub struct TextBuf<'sval>(_);
Expand description

Buffer text fragments into a single contiguous string.

In no-std environments, this buffer only supports a single borrowed text fragment. Other methods will fail.

Implementations§

source§

impl<'sval> TextBuf<'sval>

source

pub fn new() -> Self

Create a new empty text buffer.

source

pub fn collect(value: &'sval impl Value + ?Sized) -> Result<Self, Error>

Buffer a text value into a contiguous string.

source

pub fn clear(&mut self)

Clear the text buffer so it can be re-used.

source

pub fn push_fragment(&mut self, fragment: &'sval str) -> Result<(), Error>

Push a borrowed text fragment onto the buffer.

source

pub fn push_fragment_computed(&mut self, fragment: &str) -> Result<(), Error>

Push a computed text fragment onto the buffer.

If the std feature of this library is enabled, this method will buffer the fragment. In no-std environments this method will fail.

source

pub fn as_borrowed_str(&self) -> Option<&'sval str>

Try get the contents of the buffer as a string borrowed for the 'sval lifetime.

source

pub fn as_str(&self) -> &str

Get the contents of the buffer as a string.

Trait Implementations§

source§

impl<'sval> AsRef<str> for TextBuf<'sval>

source§

fn as_ref(&self) -> &str

Converts this type into a shared reference of the (usually inferred) input type.
source§

impl<'sval> Clone for TextBuf<'sval>

source§

fn clone(&self) -> TextBuf<'sval>

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<'sval> Debug for TextBuf<'sval>

source§

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

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

impl<'sval> Default for TextBuf<'sval>

source§

fn default() -> Self

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

impl<'sval> From<&'sval str> for TextBuf<'sval>

source§

fn from(fragment: &'sval str) -> Self

Converts to this type from the input type.
source§

impl<'sval> PartialEq<TextBuf<'sval>> for TextBuf<'sval>

source§

fn eq(&self, other: &TextBuf<'sval>) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<'a> Value for TextBuf<'a>

source§

fn stream<'sval, S: Stream<'sval> + ?Sized>( &'sval self, stream: &mut S ) -> Result

Stream this value through a Stream.
source§

fn to_bool(&self) -> Option<bool>

Try convert this value into a boolean.
source§

fn to_f32(&self) -> Option<f32>

Try convert this value into a 32bit binary floating point number.
source§

fn to_f64(&self) -> Option<f64>

Try convert this value into a 64bit binary floating point number.
source§

fn to_i8(&self) -> Option<i8>

Try convert this value into a signed 8bit integer.
source§

fn to_i16(&self) -> Option<i16>

Try convert this value into a signed 16bit integer.
source§

fn to_i32(&self) -> Option<i32>

Try convert this value into a signed 32bit integer.
source§

fn to_i64(&self) -> Option<i64>

Try convert this value into a signed 64bit integer.
source§

fn to_i128(&self) -> Option<i128>

Try convert this value into a signed 128bit integer.
source§

fn to_u8(&self) -> Option<u8>

Try convert this value into an unsigned 8bit integer.
source§

fn to_u16(&self) -> Option<u16>

Try convert this value into an unsigned 16bit integer.
source§

fn to_u32(&self) -> Option<u32>

Try convert this value into an unsigned 32bit integer.
source§

fn to_u64(&self) -> Option<u64>

Try convert this value into an unsigned 64bit integer.
source§

fn to_u128(&self) -> Option<u128>

Try convert this value into an unsigned 128bit integer.
source§

fn to_text(&self) -> Option<&str>

Try convert this value into a text string.
source§

fn to_binary(&self) -> Option<&[u8]>

Try convert this value into a bitstring.
source§

impl<'sval> ValueRef<'sval> for TextBuf<'sval>

source§

fn stream_ref<S: Stream<'sval> + ?Sized>(&self, stream: &mut S) -> Result

Stream this value through a Stream.
source§

impl<'sval> Eq for TextBuf<'sval>

source§

impl<'sval> StructuralEq for TextBuf<'sval>

source§

impl<'sval> StructuralPartialEq for TextBuf<'sval>

Auto Trait Implementations§

§

impl<'sval> RefUnwindSafe for TextBuf<'sval>

§

impl<'sval> Send for TextBuf<'sval>

§

impl<'sval> Sync for TextBuf<'sval>

§

impl<'sval> Unpin for TextBuf<'sval>

§

impl<'sval> UnwindSafe for TextBuf<'sval>

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

const: unstable · source§

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

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

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

const: unstable · 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 Twhere 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 Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

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

Performs the conversion.
source§

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

§

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

The type returned in the event of a conversion error.
const: unstable · source§

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

Performs the conversion.