[−][src]Struct bytes::Rope
An immutable sequence of bytes formed by concatenation of other ByteStr
values, without copying the data in the pieces. The concatenation is
represented as a tree whose leaf nodes are each a Bytes
value.
Most of the operation here is inspired by the now-famous paper Ropes: an Alternative to Strings. hans-j. boehm, russ atkinson and michael plass.
Fundamentally the Rope algorithm represents the collection of pieces as a binary tree. BAP95 uses a Fibonacci bound relating depth to a minimum sequence length, sequences that are too short relative to their depth cause a tree rebalance. More precisely, a tree of depth d is "balanced" in the terminology of BAP95 if its length is at least F(d+2), where F(n) is the n-the Fibonacci number. Thus for depths 0, 1, 2, 3, 4, 5,... we have minimum lengths 1, 2, 3, 5, 8, 13,...
Methods
impl Rope
[src]
pub fn from_slice(bytes: &[u8]) -> Rope
[src]
pub fn of<B: ByteStr + 'static>(bytes: B) -> Rope
[src]
Returns a Rope consisting of the supplied Bytes as a single segment.
pub fn len(&self) -> usize
[src]
pub fn is_empty(&self) -> bool
[src]
Trait Implementations
impl<'a> Source for &'a Rope
[src]
impl ByteStr for Rope
[src]
type Buf = RopeBuf
ⓘImportant traits for RopeBuffn buf(&self) -> RopeBuf
[src]
fn concat<B: ByteStr + 'static>(&self, other: &B) -> Bytes
[src]
fn len(&self) -> usize
[src]
fn slice(&self, begin: usize, end: usize) -> Bytes
[src]
fn is_empty(&self) -> bool
[src]
fn slice_from(&self, begin: usize) -> Bytes
[src]
fn slice_to(&self, end: usize) -> Bytes
[src]
fn split_at(&self, mid: usize) -> (Bytes, Bytes)
[src]
impl ToBytes for Rope
[src]
impl Clone for Rope
[src]
impl<B: ByteStr> PartialEq<B> for Rope
[src]
impl Index<usize> for Rope
[src]
Auto Trait Implementations
impl Send for Rope
impl Sync for Rope
impl Unpin for Rope
impl UnwindSafe for Rope
impl RefUnwindSafe for Rope
Blanket Implementations
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> From<T> for T
[src]
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,