InlineFlexStr

Struct InlineFlexStr 

Source
pub struct InlineFlexStr<S: ?Sized + StringToFromBytes> { /* private fields */ }
Expand description

Inline bytes type - used to store small strings inline

Implementations§

Source§

impl<S: ?Sized + StringToFromBytes> InlineFlexStr<S>

Source

pub fn try_from_type(s: &S) -> Result<Self, TooLongForInlining>

Attempt to create an inlined string from a borrowed string. Returns None if the string is too long.

Source

pub fn as_raw_bytes(&self) -> &[u8]

Available on non-crate feature safe only.

Borrow the inline bytes as a raw byte slice (NOTE: includes trailing NUL for CStr)

Source

pub fn as_ref_type(&self) -> &S

Borrow a string reference as &S

Source

pub fn as_bytes(&self) -> &[u8]

Borrow the inline bytes as bytes

Source

pub fn into_owned_type(self) -> S::Owned
where S::Owned: From<Box<S>>,

Consume a string and convert it to an owned string.

Source

pub fn to_owned_type(&self) -> S::Owned

Convert a string reference to an owned string.

Source§

impl<S: ?Sized + StringFromBytesMut> InlineFlexStr<S>

Source

pub fn as_mut_type(&mut self) -> &mut S

Borrow the inline string as a mutable string reference

Trait Implementations§

Source§

impl<S: ?Sized + StringFromBytesMut> AsMut<S> for InlineFlexStr<S>

Source§

fn as_mut(&mut self) -> &mut S

Converts this type into a mutable reference of the (usually inferred) input type.
Source§

impl<S> AsRef<str> for InlineFlexStr<S>

Available on crate feature str only.
Source§

fn as_ref(&self) -> &str

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

impl<S: ?Sized + StringToFromBytes> Borrow<S> for InlineFlexStr<S>

Source§

fn borrow(&self) -> &S

Immutably borrows from an owned value. Read more
Source§

impl<S: ?Sized + StringFromBytesMut> BorrowMut<S> for InlineFlexStr<S>

Source§

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

Mutably borrows from an owned value. Read more
Source§

impl<S: ?Sized + StringToFromBytes> Clone for InlineFlexStr<S>

Source§

fn clone(&self) -> Self

Returns a duplicate 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<S: Debug + ?Sized + StringToFromBytes> Debug for InlineFlexStr<S>

Source§

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

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

impl<S: ?Sized + StringToFromBytes> Default for InlineFlexStr<S>
where for<'a> &'a S: Default,

Source§

fn default() -> Self

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

impl<S: ?Sized + StringToFromBytes> Deref for InlineFlexStr<S>

Source§

type Target = S

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Self::Target

Dereferences the value.
Source§

impl<S: ?Sized + StringFromBytesMut> DerefMut for InlineFlexStr<S>

Source§

fn deref_mut(&mut self) -> &mut Self::Target

Mutably dereferences the value.
Source§

impl<S> Display for InlineFlexStr<S>

Source§

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

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

impl FromStr for InlineFlexStr<str>

Available on crate feature str only.
Source§

type Err = TooLongForInlining

The associated error which can be returned from parsing.
Source§

fn from_str(s: &str) -> Result<Self, Self::Err>

Parses a string s to return a value of this type. Read more
Source§

impl<S> Hash for InlineFlexStr<S>

Source§

fn hash<H: Hasher>(&self, state: &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<S, I: SliceIndex<S>> Index<I> for InlineFlexStr<S>
where S: Index<I> + ?Sized + StringToFromBytes,

Source§

type Output = <S as Index<I>>::Output

The returned type after indexing.
Source§

fn index(&self, index: I) -> &Self::Output

Performs the indexing (container[index]) operation. Read more
Source§

impl<S, I: SliceIndex<S>> IndexMut<I> for InlineFlexStr<S>

Source§

fn index_mut(&mut self, index: I) -> &mut Self::Output

Performs the mutable indexing (container[index]) operation. Read more
Source§

impl<S> Ord for InlineFlexStr<S>
where S: Ord + ?Sized + StringToFromBytes,

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) -> Self
where Self: Sized,

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

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

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

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

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

impl<S> PartialEq<&str> for InlineFlexStr<S>

Available on crate feature str only.
Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<S> PartialEq<Cow<'_, str>> for InlineFlexStr<S>

Available on crate feature str only.
Source§

fn eq(&self, other: &Cow<'_, str>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<S> PartialEq<InlineFlexStr<S>> for &str

Available on crate feature str only.
Source§

fn eq(&self, other: &InlineFlexStr<S>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<S> PartialEq<InlineFlexStr<S>> for Cow<'_, str>

Available on crate feature str only.
Source§

fn eq(&self, other: &InlineFlexStr<S>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<S> PartialEq<InlineFlexStr<S>> for String

Available on crate feature str only.
Source§

fn eq(&self, other: &InlineFlexStr<S>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<S> PartialEq<InlineFlexStr<S>> for str

Available on crate feature str only.
Source§

fn eq(&self, other: &InlineFlexStr<S>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<S> PartialEq<String> for InlineFlexStr<S>

Available on crate feature str only.
Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<S> PartialEq<str> for InlineFlexStr<S>

Available on crate feature str only.
Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<S> PartialEq for InlineFlexStr<S>

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<S> PartialOrd for InlineFlexStr<S>

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

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

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

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

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl<S: ?Sized + StringToFromBytes + 'static> StringLike<S> for InlineFlexStr<S>

Source§

fn as_ref_type(&self) -> &S

Borrow a string reference as &S
Source§

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

Borrow the string as bytes
Source§

fn into_owned_type(self) -> S::Owned
where S::Owned: From<Box<S>>,

Consume a string and convert it to an owned string. S::to_owned is called on Borrowed/Inlined/RefCounted variants. Boxed variants are converted directly into S::Owned (most likely without copy or allocation).
Source§

fn to_owned_type(&self) -> S::Owned

Convert a string reference to an owned string. S::to_owned is called on all variants.
Source§

fn is_empty(&self) -> bool

Returns true if this is an empty string
Source§

fn len(&self) -> usize

Returns the length of this string in bytes
Source§

fn as_str(&self) -> &str
where S: AsRef<str>,

Borrow the string as an &str
Source§

fn into_string(self) -> String
where <S as ToOwned>::Owned: Into<String> + From<Box<S>>,

Consume a string and convert it to a String
Source§

fn to_string(&self) -> String
where <S as ToOwned>::Owned: Into<String>,

Convert a string reference to a String
Source§

impl<S> ToSocketAddrs for InlineFlexStr<S>

Available on crate feature std only.
Source§

type Iter = <S as ToSocketAddrs>::Iter

Returned iterator over socket addresses which this type may correspond to.
Source§

fn to_socket_addrs(&self) -> Result<<S as ToSocketAddrs>::Iter>

Converts this object to an iterator of resolved SocketAddrs. Read more
Source§

impl<'s> TryFrom<&'s [u8]> for InlineFlexStr<str>

Available on crate feature str only.
Source§

type Error = TooLongOrUtf8Error

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

fn try_from(s: &'s [u8]) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl<'s> TryFrom<&'s OsStr> for InlineFlexStr<str>

Available on crate features str and std only.
Source§

type Error = TooLongOrUtf8Error

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

fn try_from(s: &'s OsStr) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl<'s> TryFrom<&'s Path> for InlineFlexStr<str>

Available on crate features str and std only.
Source§

type Error = TooLongOrUtf8Error

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

fn try_from(s: &'s Path) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl<'s> TryFrom<&'s str> for InlineFlexStr<str>

Available on crate feature str only.
Source§

type Error = TooLongForInlining

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

fn try_from(s: &'s str) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl<S: ?Sized + StringToFromBytes> Copy for InlineFlexStr<S>

Source§

impl<S> Eq for InlineFlexStr<S>
where S: Eq + ?Sized + StringToFromBytes,

Auto Trait Implementations§

§

impl<S> Freeze for InlineFlexStr<S>
where S: ?Sized,

§

impl<S> RefUnwindSafe for InlineFlexStr<S>
where S: RefUnwindSafe + ?Sized,

§

impl<S> Send for InlineFlexStr<S>
where S: Send + ?Sized,

§

impl<S> Sync for InlineFlexStr<S>
where S: Sync + ?Sized,

§

impl<S> Unpin for InlineFlexStr<S>
where S: Unpin + ?Sized,

§

impl<S> UnwindSafe for InlineFlexStr<S>
where S: UnwindSafe + ?Sized,

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

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

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

Source§

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>,

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.