FerroUI/ docs

Search guides, controls, Rust APIs, and XAML.

    GitHub ↗

    ReadOnlyMemory

    struct · ferroui-base · v0.5.0

    struct ReadOnlyMemory<T>
    

    An immutable, reference counted slice of a shared buffer.

    Cloning and slicing never copy the elements; they bump one reference count.

    View source

    Members

    empty

    const fn empty() -> Self
    

    The empty memory (C# default / ReadOnlyMemory<T>.Empty).

    Source

    new

    fn new(owner: Rc<[T]>) -> Self
    

    Wraps a whole shared buffer.

    Source

    with_range

    fn with_range(owner: Rc<[T]>, start: usize, length: usize) -> Self
    

    Wraps length elements of a shared buffer starting at start.

    Panics when the range is outside the buffer.

    Source

    from_vec

    fn from_vec(values: Vec<T>) -> Self
    

    Takes ownership of a vector.

    Source

    len

    fn len(self: &Self) -> usize
    

    The number of elements (C# Length).

    Source

    is_empty

    fn is_empty(self: &Self) -> bool
    

    Whether the memory has no elements (C# IsEmpty).

    Source

    span

    fn span(self: &Self) -> &[T]
    

    The elements (C# Span).

    Source

    slice_from

    fn slice_from(self: &Self, start: usize) -> Self
    

    The elements from start to the end (C# Slice(start)).

    Panics when start is outside the memory.

    Source

    slice

    fn slice(self: &Self, start: usize, length: usize) -> Self
    

    length elements starting at start (C# Slice(start, length)).

    Panics when the range is outside the memory.

    Source

    offset_in_owner

    fn offset_in_owner(self: &Self) -> usize
    

    The offset of this memory inside its underlying buffer.

    Source

    owner

    fn owner(self: &Self) -> Option<&Rc<[T]>>
    

    The underlying buffer, when there is one.

    Source

    shares_owner_with

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

    Whether both memories view the same buffer (regardless of range).

    Source

    from_slice

    fn from_slice(values: &[T]) -> Self
    

    Copies a slice into a new shared buffer.

    Source

    to_vec

    fn to_vec(self: &Self) -> Vec<T>
    

    Copies the elements out (C# ToArray).

    Source

    from_str

    fn from_str(text: &str) -> Self
    

    Encodes a string as UTF-16 code units (C# string.AsMemory()).

    Source

    to_string_lossy

    fn to_string_lossy(self: &Self) -> String
    

    Decodes the UTF-16 code units, replacing lone surrogates with U+FFFD.

    Source

    Trait implementations

    • Send
    • Sync
    • Freeze
    • UnsafeUnpin
    • Unpin
    • UnwindSafe
    • RefUnwindSafe
    • PropertyValue
    • AnyValue
    • ClassDefaults
    • Borrow<T>
    • BorrowMut<T>
    • CloneToUninit
    • Into<U>
    • From<T>
    • TryInto<U>
    • TryFrom<U>
    • Any
    • ToOwned
    • ErasedDestructor
    • IntoEither
    • Clone
    • Default
    • Debug
    • PartialEq
    • From<Vec<T>>
    • From<Rc<[T]>>
    • From<&str>

    Availability

    Extracted for aarch64-apple-darwin. Cargo features are listed in the crate index.