Struct Array

Source
#[repr(C)]
pub struct Array<T> { pub index: u32, pub len: u32, /* private fields */ }
Expand description

A pointer to contiguous T elements in a slab.

use crabslab::{Array, CpuSlab, GrowableSlab, Id, Slab, SlabItem};

let ints = [1, 2, 3, 4, 5u32];
let mut slab = CpuSlab::new(vec![]);
let array = slab.append_array(&ints);
for (i, id) in array.iter().enumerate() {
    let value = slab.read(id);
    assert_eq!(ints[i], value);
}

Fieldsยง

ยงindex: u32ยงlen: u32

Implementationsยง

Sourceยง

impl<T> Array<T>

Source

pub const NONE: Array<T>

Source

pub const fn new(index: u32, len: u32) -> Array<T>

Source

pub fn len(&self) -> usize

Source

pub fn is_empty(&self) -> bool

Source

pub fn is_null(&self) -> bool

Source

pub fn contains_index(&self, index: usize) -> bool

Source

pub fn at(&self, index: usize) -> Id<T>
where T: SlabItem,

Source

pub fn starting_index(&self) -> usize

Source

pub fn iter(&self) -> ArrayIter<T>

Source

pub fn into_u32_array(self) -> Array<u32>
where T: SlabItem,

Convert this array into a u32 array.

Source

pub fn sub_slab<'a>(&'a self, slab: &'a [u32]) -> &'a [u32]
where T: SlabItem,

Return the slice of the slab that this array represents.

Sourceยง

impl Array<u32>

Source

pub fn union(&mut self, other: &Array<u32>)

Trait Implementationsยง

Sourceยง

impl<T> Clone for Array<T>

Sourceยง

fn clone(&self) -> Array<T>

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<T> Debug for Array<T>

Sourceยง

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

Formats the value using the given formatter. Read more
Sourceยง

impl<T> Default for Array<T>
where T: SlabItem,

Sourceยง

fn default() -> Array<T>

Returns the โ€œdefault valueโ€ for a type. Read more
Sourceยง

impl<T> From<Id<T>> for Array<T>

An Id<T> is an Array<T> with a length of 1.

Sourceยง

fn from(id: Id<T>) -> Array<T>

Converts to this type from the input type.
Sourceยง

impl<T> PartialEq for Array<T>

Sourceยง

fn eq(&self, other: &Array<T>) -> 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<T> SlabItem for Array<T>
where T: SlabItem,

Sourceยง

const SLAB_SIZE: usize = 2usize

The number of u32s this type occupies in a slab of &[u32].
Sourceยง

fn write_slab(&self, index: usize, slab: &mut [u32]) -> usize

Write the type into the slab at starting index and return the new index. Read more
Sourceยง

fn read_slab(index: usize, slab: &[u32]) -> Array<T>

Read the type out of the slab at index.
Sourceยง

impl<T> Copy for Array<T>

Auto Trait Implementationsยง

ยง

impl<T> Freeze for Array<T>

ยง

impl<T> RefUnwindSafe for Array<T>
where T: RefUnwindSafe,

ยง

impl<T> Send for Array<T>
where T: Send,

ยง

impl<T> Sync for Array<T>
where T: Sync,

ยง

impl<T> Unpin for Array<T>
where T: Unpin,

ยง

impl<T> UnwindSafe for Array<T>
where T: UnwindSafe,

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> Downcast<T> for T

Sourceยง

impl<T> Downcast for T
where T: Any,

Sourceยง

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.
Sourceยง

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
Sourceยง

fn as_any(&self) -> &(dyn Any + 'static)

Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Anyโ€™s vtable from &Traitโ€™s.
Sourceยง

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Anyโ€™s vtable from &mut Traitโ€™s.
Sourceยง

impl<T> DowncastSync for T
where T: Any + Send + Sync,

Sourceยง

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Send + Sync>

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait.
Sourceยง

impl<T> From<T> for T

Sourceยง

fn from(t: T) -> T

Returns the argument unchanged.

Sourceยง

impl<T> Instrument for T

Sourceยง

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Sourceยง

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoEither for T

Sourceยง

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Sourceยง

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Sourceยง

impl<T> Pointable for T

Sourceยง

const ALIGN: usize

The alignment of pointer.
Sourceยง

type Init = T

The type for initializers.
Sourceยง

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Sourceยง

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Sourceยง

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Sourceยง

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Sourceยง

impl<R, P> ReadPrimitive<R> for P
where R: Read + ReadEndian<P>, P: Default,

Sourceยง

fn read_from_little_endian(read: &mut R) -> Result<Self, Error>

Read this value from the supplied reader. Same as ReadEndian::read_from_little_endian().
Sourceยง

fn read_from_big_endian(read: &mut R) -> Result<Self, Error>

Read this value from the supplied reader. Same as ReadEndian::read_from_big_endian().
Sourceยง

fn read_from_native_endian(read: &mut R) -> Result<Self, Error>

Read this value from the supplied reader. Same as ReadEndian::read_from_native_endian().
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, 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.
Sourceยง

impl<T> Upcast<T> for T

Sourceยง

impl<T> WithSubscriber for T

Sourceยง

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Sourceยง

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Sourceยง

impl<T> WasmNotSend for T
where T: Send,

Sourceยง

impl<T> WasmNotSendSync for T

Sourceยง

impl<T> WasmNotSync for T
where T: Sync,