Skip to main content

StringLayout

Struct StringLayout 

Source
pub struct StringLayout {
    pub len_offset: usize,
    pub data_offset: usize,
    pub is_sso: bool,
    pub sso_max_len: usize,
    pub sso_total_size: usize,
}
Expand description

Memory layout for a string object.

OxiLean strings are heap-allocated objects with a reference count header, a length field, and an inline (or pointer-to) UTF-8 byte array.

+--------+---------+--------+---------+----------+
| RC (8) | Tag (1) | Flags  | Len (4) | Data ... |
+--------+---------+--------+---------+----------+

Fields§

§len_offset: usize

Byte offset of the length field.

§data_offset: usize

Byte offset of the UTF-8 data.

§is_sso: bool

Whether the string is SSO (short-string optimized / inline).

§sso_max_len: usize

Maximum length for SSO strings.

§sso_total_size: usize

Total allocated size for an SSO string (fixed).

Implementations§

Source§

impl StringLayout

Source

pub fn standard() -> Self

Standard (non-SSO) string layout.

Source

pub fn sso(max_len: usize) -> Self

Short-string-optimized layout (inline up to max_len bytes).

Source

pub fn alloc_size(&self, str_len: usize) -> usize

Compute the total allocation size for a given string length.

Trait Implementations§

Source§

impl Clone for StringLayout

Source§

fn clone(&self) -> StringLayout

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for StringLayout

Source§

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

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

impl Display for StringLayout

Source§

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

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

impl Eq for StringLayout

Source§

impl PartialEq for StringLayout

Source§

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

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

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

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for StringLayout

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