Type Alias tendril::tendril::ByteTendril

source ·
pub type ByteTendril = Tendril<Bytes>;
Expand description

Tendril for storing binary data.

Aliased Type§

struct ByteTendril {
    ptr: Cell<NonZeroUsize>,
    buf: UnsafeCell<Buffer>,
    marker: PhantomData<*mut Bytes>,
    refcount_marker: PhantomData<NonAtomic>,
}

Fields§

§ptr: Cell<NonZeroUsize>§buf: UnsafeCell<Buffer>§marker: PhantomData<*mut Bytes>§refcount_marker: PhantomData<NonAtomic>

Implementations§

source§

impl<F, A> Tendril<F, A>where F: Format, A: Atomicity,

source

pub fn new() -> Tendril<F, A>

Create a new, empty Tendril in any format.

source

pub fn with_capacity(capacity: u32) -> Tendril<F, A>

Create a new, empty Tendril with a specified capacity.

source

pub fn reserve(&mut self, additional: u32)

Reserve space for additional bytes.

This is only a suggestion. There are cases where Tendril will decline to allocate until the buffer is actually modified.

source

fn force_reserve(&mut self, additional: u32)

Reserve space for additional bytes, even for shared buffers.

source

pub fn len32(&self) -> u32

Get the length of the Tendril.

This is named not to conflict with len() on the underlying slice, if any.

source

pub fn is_shared(&self) -> bool

Is the backing buffer shared?

source

pub fn is_shared_with(&self, other: &Tendril<F, A>) -> bool

Is the backing buffer shared with this other Tendril?

source

pub fn clear(&mut self)

Truncate to length 0 without discarding any owned storage.

source

pub fn try_from_byte_slice(x: &[u8]) -> Result<Tendril<F, A>, ()>

Build a Tendril by copying a byte slice, if it conforms to the format.

source

pub fn as_bytes(&self) -> &Tendril<Bytes, A>

View as uninterpreted bytes.

source

pub fn into_bytes(self) -> Tendril<Bytes, A>

Convert into uninterpreted bytes.

source

pub fn into_send(self) -> SendTendril<F>

Convert self into a type which is Send.

If the tendril is owned or inline, this is free, but if it’s shared this will entail a copy of the contents.

source

pub fn as_superset<Super>(&self) -> &Tendril<Super, A>where F: SubsetOf<Super>, Super: Format,

View as a superset format, for free.

source

pub fn into_superset<Super>(self) -> Tendril<Super, A>where F: SubsetOf<Super>, Super: Format,

Convert into a superset format, for free.

source

pub fn try_as_subset<Sub>(&self) -> Result<&Tendril<Sub, A>, ()>where Sub: SubsetOf<F>,

View as a subset format, if the Tendril conforms to that subset.

source

pub fn try_into_subset<Sub>(self) -> Result<Tendril<Sub, A>, Self>where Sub: SubsetOf<F>,

Convert into a subset format, if the Tendril conforms to that subset.

source

pub fn try_reinterpret_view<Other>(&self) -> Result<&Tendril<Other, A>, ()>where Other: Format,

View as another format, if the bytes of the Tendril are valid for that format.

source

pub fn try_reinterpret<Other>(self) -> Result<Tendril<Other, A>, Self>where Other: Format,

Convert into another format, if the Tendril conforms to that format.

This only re-validates the existing bytes under the new format. It will not change the byte content of the tendril!

See the encode and decode methods for character encoding conversion.

source

pub fn try_push_bytes(&mut self, buf: &[u8]) -> Result<(), ()>

Push some bytes onto the end of the Tendril, if they conform to the format.

source

pub fn push_tendril(&mut self, other: &Tendril<F, A>)

Push another Tendril onto the end of this one.

source

pub fn try_subtendril( &self, offset: u32, length: u32 ) -> Result<Tendril<F, A>, SubtendrilError>

Attempt to slice this Tendril as a new Tendril.

This will share the buffer when possible. Mutating a shared buffer will copy the contents.

The offset and length are in bytes. The function will return Err if these are out of bounds, or if the resulting slice does not conform to the format.

source

pub fn subtendril(&self, offset: u32, length: u32) -> Tendril<F, A>

Slice this Tendril as a new Tendril.

Panics on bounds or validity check failure.

source

pub fn try_pop_front(&mut self, n: u32) -> Result<(), SubtendrilError>

Try to drop n bytes from the front.

Returns Err if the bytes are not available, or the suffix fails validation.

source

pub fn pop_front(&mut self, n: u32)

Drop n bytes from the front.

Panics if the bytes are not available, or the suffix fails validation.

source

pub fn try_pop_back(&mut self, n: u32) -> Result<(), SubtendrilError>

Drop n bytes from the back.

Returns Err if the bytes are not available, or the prefix fails validation.

source

pub fn pop_back(&mut self, n: u32)

Drop n bytes from the back.

Panics if the bytes are not available, or the prefix fails validation.

source

pub unsafe fn reinterpret_view_without_validating<Other>( &self ) -> &Tendril<Other, A>where Other: Format,

View as another format, without validating.

source

pub unsafe fn reinterpret_without_validating<Other>(self) -> Tendril<Other, A>where Other: Format,

Convert into another format, without validating.

source

pub unsafe fn from_byte_slice_without_validating(x: &[u8]) -> Tendril<F, A>

Build a Tendril by copying a byte slice, without validating.

source

pub unsafe fn push_bytes_without_validating(&mut self, buf: &[u8])

Push some bytes onto the end of the Tendril, without validating.

source

pub unsafe fn unsafe_subtendril( &self, offset: u32, length: u32 ) -> Tendril<F, A>

Slice this Tendril as a new Tendril.

Does not check validity or bounds!

source

pub unsafe fn unsafe_pop_front(&mut self, n: u32)

Drop n bytes from the front.

Does not check validity or bounds!

source

pub unsafe fn unsafe_pop_back(&mut self, n: u32)

Drop n bytes from the back.

Does not check validity or bounds!

source

unsafe fn incref(&self)

source

unsafe fn make_buf_shared(&self)

source

fn make_owned(&mut self)

source

unsafe fn make_owned_with_capacity(&mut self, cap: u32)

source

unsafe fn header(&self) -> *mut Header<A>

source

unsafe fn assume_buf(&self) -> (Buf32<Header<A>>, bool, u32)

source

unsafe fn inline(x: &[u8]) -> Tendril<F, A>

source

unsafe fn owned(x: Buf32<Header<A>>) -> Tendril<F, A>

source

unsafe fn owned_copy(x: &[u8]) -> Tendril<F, A>

source

unsafe fn shared(buf: Buf32<Header<A>>, off: u32, len: u32) -> Tendril<F, A>

source

fn as_byte_slice<'a>(&'a self) -> &'a [u8]

source

fn as_mut_byte_slice<'a>(&'a mut self) -> &'a mut [u8]

source

unsafe fn raw_len(&self) -> u32

source

unsafe fn set_len(&mut self, len: u32)

source

unsafe fn aux(&self) -> u32

source

unsafe fn set_aux(&self, aux: u32)

source§

impl<F, A> Tendril<F, A>where F: SliceFormat, A: Atomicity,

source

pub fn from_slice(x: &F::Slice) -> Tendril<F, A>

Build a Tendril by copying a slice.

source

pub fn push_slice(&mut self, x: &F::Slice)

Push a slice onto the end of the Tendril.

source§

impl<F, A> Tendril<F, A>where F: for<'a> CharFormat<'a>, A: Atomicity,

source

pub fn pop_front_char<'a>(&'a mut self) -> Option<char>

Remove and return the first character, if any.

source

pub fn pop_front_char_run<'a, C, R>( &'a mut self, classify: C ) -> Option<(Tendril<F, A>, R)>where C: FnMut(char) -> R, R: PartialEq,

Remove and return a run of characters at the front of the Tendril which are classified the same according to the function classify.

Returns None on an empty string.

source

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

Push a character, if it can be represented in this format.

source§

impl<F, A> Tendril<F, A>where A: Atomicity, F: SliceFormat<Slice = [u8]>,

source

pub unsafe fn push_uninitialized(&mut self, n: u32)

Push “uninitialized bytes” onto the end.

Really, this grows the tendril without writing anything to the new area. It’s only defined for byte tendrils because it’s only useful if you plan to then mutate the buffer.

source§

impl<A> Tendril<Bytes, A>where A: Atomicity,

source

pub fn decode_utf8_lossy<F>(self, push_utf8: F) -> Option<IncompleteUtf8>where F: FnMut(Tendril<UTF8, A>),

Trait Implementations§

source§

impl<F, A> AsRef<<F as SliceFormat>::Slice> for Tendril<F, A>where F: SliceFormat, A: Atomicity,

source§

fn as_ref(&self) -> &F::Slice

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

impl<F, A> Borrow<[u8]> for Tendril<F, A>where F: SliceFormat, A: Atomicity,

source§

fn borrow(&self) -> &[u8]

Immutably borrows from an owned value. Read more
source§

impl<F, A> Clone for Tendril<F, A>where F: Format, A: Atomicity,

source§

fn clone(&self) -> Tendril<F, A>

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<F, A> Debug for Tendril<F, A>where F: SliceFormat + Default + Debug, <F as SliceFormat>::Slice: Debug, A: Atomicity,

source§

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

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

impl<F, A> Default for Tendril<F, A>where F: Format, A: Atomicity,

source§

fn default() -> Tendril<F, A>

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

impl<F, A> Deref for Tendril<F, A>where F: SliceFormat, A: Atomicity,

§

type Target = <F as SliceFormat>::Slice

The resulting type after dereferencing.
source§

fn deref(&self) -> &F::Slice

Dereferences the value.
source§

impl<F, A> DerefMut for Tendril<F, A>where F: SliceFormat, A: Atomicity,

source§

fn deref_mut(&mut self) -> &mut F::Slice

Mutably dereferences the value.
source§

impl<F, A> Drop for Tendril<F, A>where F: Format, A: Atomicity,

source§

fn drop(&mut self)

Executes the destructor for this type. Read more
source§

impl<'a, A> Extend<&'a [u8]> for Tendril<Bytes, A>where A: Atomicity,

source§

fn extend<I>(&mut self, iterable: I)where I: IntoIterator<Item = &'a [u8]>,

Extends a collection with the contents of an iterator. Read more
source§

fn extend_one(&mut self, item: A)

🔬This is a nightly-only experimental API. (extend_one)
Extends a collection with exactly one element.
source§

fn extend_reserve(&mut self, additional: usize)

🔬This is a nightly-only experimental API. (extend_one)
Reserves capacity in a collection for the given number of additional elements. Read more
source§

impl<'a, F, A> Extend<&'a Tendril<F, A>> for Tendril<F, A>where F: Format + 'a, A: Atomicity,

source§

fn extend<I>(&mut self, iterable: I)where I: IntoIterator<Item = &'a Tendril<F, A>>,

Extends a collection with the contents of an iterator. Read more
source§

fn extend_one(&mut self, item: A)

🔬This is a nightly-only experimental API. (extend_one)
Extends a collection with exactly one element.
source§

fn extend_reserve(&mut self, additional: usize)

🔬This is a nightly-only experimental API. (extend_one)
Reserves capacity in a collection for the given number of additional elements. Read more
source§

impl<'a, A> Extend<&'a u8> for Tendril<Bytes, A>where A: Atomicity,

source§

fn extend<I>(&mut self, iterable: I)where I: IntoIterator<Item = &'a u8>,

Extends a collection with the contents of an iterator. Read more
source§

fn extend_one(&mut self, item: A)

🔬This is a nightly-only experimental API. (extend_one)
Extends a collection with exactly one element.
source§

fn extend_reserve(&mut self, additional: usize)

🔬This is a nightly-only experimental API. (extend_one)
Reserves capacity in a collection for the given number of additional elements. Read more
source§

impl<A> Extend<u8> for Tendril<Bytes, A>where A: Atomicity,

source§

fn extend<I>(&mut self, iterable: I)where I: IntoIterator<Item = u8>,

Extends a collection with the contents of an iterator. Read more
source§

fn extend_one(&mut self, item: A)

🔬This is a nightly-only experimental API. (extend_one)
Extends a collection with exactly one element.
source§

fn extend_reserve(&mut self, additional: usize)

🔬This is a nightly-only experimental API. (extend_one)
Reserves capacity in a collection for the given number of additional elements. Read more
source§

impl<'a, F, A> From<&'a <F as SliceFormat>::Slice> for Tendril<F, A>where F: SliceFormat, A: Atomicity,

source§

fn from(input: &F::Slice) -> Tendril<F, A>

Converts to this type from the input type.
source§

impl<F, A> From<SendTendril<F>> for Tendril<F, A>where F: Format, A: Atomicity,

source§

fn from(send: SendTendril<F>) -> Tendril<F, A>

Converts to this type from the input type.
source§

impl<'a, A> FromIterator<&'a [u8]> for Tendril<Bytes, A>where A: Atomicity,

source§

fn from_iter<I>(iterable: I) -> Selfwhere I: IntoIterator<Item = &'a [u8]>,

Creates a value from an iterator. Read more
source§

impl<'a, F, A> FromIterator<&'a Tendril<F, A>> for Tendril<F, A>where F: Format + 'a, A: Atomicity,

source§

fn from_iter<I>(iterable: I) -> Selfwhere I: IntoIterator<Item = &'a Tendril<F, A>>,

Creates a value from an iterator. Read more
source§

impl<'a, A> FromIterator<&'a u8> for Tendril<Bytes, A>where A: Atomicity,

source§

fn from_iter<I>(iterable: I) -> Selfwhere I: IntoIterator<Item = &'a u8>,

Creates a value from an iterator. Read more
source§

impl<A> FromIterator<u8> for Tendril<Bytes, A>where A: Atomicity,

source§

fn from_iter<I>(iterable: I) -> Selfwhere I: IntoIterator<Item = u8>,

Creates a value from an iterator. Read more
source§

impl<F, A> Hash for Tendril<F, A>where F: Format, A: Atomicity,

source§

fn hash<H: Hasher>(&self, hasher: &mut H)

Feeds this value into the given Hasher. Read more
1.3.0 · source§

fn hash_slice<H>(data: &[Self], state: &mut H)where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
source§

impl<F, A> Ord for Tendril<F, A>where F: SliceFormat, <F as SliceFormat>::Slice: Ord, A: Atomicity,

source§

fn cmp(&self, other: &Self) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · source§

fn max(self, other: Self) -> Selfwhere Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · source§

fn min(self, other: Self) -> Selfwhere Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · source§

fn clamp(self, min: Self, max: Self) -> Selfwhere Self: Sized + PartialOrd<Self>,

Restrict a value to a certain interval. Read more
source§

impl<F, A> PartialEq<Tendril<F, A>> for Tendril<F, A>where F: Format, A: Atomicity,

source§

fn eq(&self, other: &Self) -> bool

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

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

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

impl<F, A> PartialOrd<Tendril<F, A>> for Tendril<F, A>where F: SliceFormat, <F as SliceFormat>::Slice: PartialOrd, A: Atomicity,

source§

fn partial_cmp(&self, other: &Self) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · source§

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

This method tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · source§

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

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · source§

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

This method tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · source§

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

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
source§

impl<A> Write for Tendril<Bytes, A>where A: Atomicity,

source§

fn write(&mut self, buf: &[u8]) -> Result<usize>

Write a buffer into this writer, returning how many bytes were written. Read more
source§

fn write_all(&mut self, buf: &[u8]) -> Result<()>

Attempts to write an entire buffer into this writer. Read more
source§

fn flush(&mut self) -> Result<()>

Flush this output stream, ensuring that all intermediately buffered contents reach their destination. Read more
1.36.0 · source§

fn write_vectored(&mut self, bufs: &[IoSlice<'_>]) -> Result<usize, Error>

Like write, except that it writes from a slice of buffers. Read more
source§

fn is_write_vectored(&self) -> bool

🔬This is a nightly-only experimental API. (can_vector)
Determines if this Writer has an efficient write_vectored implementation. Read more
source§

fn write_all_vectored(&mut self, bufs: &mut [IoSlice<'_>]) -> Result<(), Error>

🔬This is a nightly-only experimental API. (write_all_vectored)
Attempts to write multiple buffers into this writer. Read more
1.0.0 · source§

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

Writes a formatted string into this writer, returning any error encountered. Read more
1.0.0 · source§

fn by_ref(&mut self) -> &mut Selfwhere Self: Sized,

Creates a “by reference” adapter for this instance of Write. Read more
source§

impl<F, A> Eq for Tendril<F, A>where F: Format, A: Atomicity,

source§

impl<F, A> Send for Tendril<F, A>where F: Format, A: Atomicity + Sync,