[][src]Struct bigbit::linkedbytes::LBString

pub struct LBString(_);

A Unicode string stored using the Linked Bytes format.

This is more compact than all of the current UTF formats (namely, UTF-1, 7, 8, 16, let alone 32), since no surrogate pairs are used. Instead, the Linked Bytes format is leveraged, with separate codepoints being stored as individual Linked Bytes numbers. Both the link/end bits of the bytes and length of the entire message, either via the null terminator (which still works since a linking 0 has the most significant bit set to 1 and cannot be confused with the null terminator when reinterpreted as u8) or via storing it separately (as Rust Strings do), are available. This means that the UTF-32 number of each codepoint can be encoded using the usual Linked Bytes format, with the link bit cleared in a byte indicating that one character has ended and a new one is coming next.

Usage

Conversion from String or &str:

static MY_STRING: &str = "My string!";
let stdstring = String::from("This is a standard string!");

let my_string_lb = LBString::from(MY_STRING); // Creates an LBString from a string slice
let stdstring_lb = LBString::from(stdstring); // Creates an LBString from a String
let my_string_lb_2 = MY_STRING.chars().collect::<LBString>(); // Creates an LBString from an iterator

Methods

impl LBString[src]

pub fn chars(&self) -> impl Iterator<Item = char> + '_[src]

Returns an iterator over the codepoints in the string.

This is the core method of this type. Most other methods use this to perform more complex operations, such as conversion from an &str.

pub fn inner(&self) -> &LBSequence[src]

Returns an immutable reference to the underlying sequence.

Trait Implementations

impl Clone for LBString[src]

impl Debug for LBString[src]

impl Display for LBString[src]

impl<'_> From<&'_ String> for LBString[src]

impl<'a> From<&'a str> for LBString[src]

impl From<LBString> for String[src]

impl From<String> for LBString[src]

impl<'a> FromIterator<&'a char> for LBString[src]

fn from_iter<I: IntoIterator<Item = &'a char>>(iter: I) -> Self[src]

Convenience implementation for collections which iterate over references to items rather than the items themselves, to avoid repetitive .copied() in calling code.

impl FromIterator<char> for LBString[src]

Auto Trait Implementations

impl Send for LBString

impl Sync for LBString

impl Unpin for LBString

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T> ToString for T where
    T: Display + ?Sized
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.