ArrayAtomBody

Struct ArrayAtomBody 

Source
#[repr(C)]
pub struct ArrayAtomBody<H, T>
where H: ArrayAtomHeader, T: 'static + Sized + Copy,
{ pub header: H, pub data: [T], }
Expand description

Abstract type for dynamically sized atom bodies.

Many dynamically sized atoms bodies have a lot of their behaviour and raw representation in common. Therefore, they are abstracted to this struct that contains a header and an array of sized items.

If you don’t want to have a header, you can use () instead.

Not all combinations of header and data items are atom bodies, but many methods rely on the combination being an atom body.

Fields§

§header: H§data: [T]

Implementations§

Source§

impl<H, T> ArrayAtomBody<H, T>
where Self: AtomBody, H: ArrayAtomHeader, T: 'static + Sized + Copy,

Source

pub unsafe fn __initialize_body<'a, W>( writer: &mut W, parameter: &H::InitializationParameter, urids: &mut CachedMap, ) -> Result<(), ()>
where W: WritingFrame<'a> + WritingFrameExt<'a, Self>,

Internal method to initialize the body.

It simply calls the initialization method of the header, the data array will be left empty.

Source

pub fn __create_ref<'a>(raw_data: &'a [u8]) -> Result<&'a Self, ()>

Internal method to create an atom body reference.

Source

pub unsafe fn push<'a, W>(writer: &mut W, value: T) -> Result<(), ()>
where W: WritingFrame<'a> + WritingFrameExt<'a, Self>,

Push another value to the data array.

In case of insufficient memory, an Err is returned.

This method assumes that the atom was already initialized, but since can’t be checked, this method is unsafe.

Source

pub unsafe fn append<'a, W>(writer: &mut W, slice: &[T]) -> Result<(), ()>
where W: WritingFrame<'a> + WritingFrameExt<'a, Self>,

Append a T slice to the data.

In case of insufficient memory, an Err is returned.

This method assumes that the atom was already initialized, but since can’t be checked, this method is unsafe.

Source§

impl ArrayAtomBody<LiteralHeader, u8>

Source

pub fn as_str(&self) -> Result<&str, Utf8Error>

Try to parse the literal data as a &str

Parsing errors are forwarded.

Source

pub fn lang(&self) -> URID

Return the language of the literal.

Source§

impl ArrayAtomBody<ObjectHeader, u8>

Source

pub fn iter<'a>( &'a self, ) -> impl Iterator<Item = (&'a PropertyHeader, &'a Atom)>

Create an iterator over all properties of the object.

This iterator is based on the ChunkIterator.

Source§

impl ArrayAtomBody<SequenceHeader, u8>

Source

pub fn time_unit(&self, urids: &mut CachedMap) -> TimeUnit

Source

pub fn iter<'a>( &'a self, urids: &mut CachedMap, ) -> impl Iterator<Item = (TimeStamp, &'a Atom)>

Source§

impl ArrayAtomBody<(), i8>

Source

pub fn as_cstr(&self) -> Result<&CStr, FromBytesWithNulError>

Try to wrap the string into a CStr reference.

This function returns an error if the internal conversion fails.

Source§

impl ArrayAtomBody<(), u8>

Source

pub fn iter(&self) -> impl Iterator<Item = &Atom>

Create an iterator over all properties of the object.

This iterator is based on the AtomIterator.

Source§

impl<T> ArrayAtomBody<VectorHeader, T>
where T: 'static + AtomBody + Sized + Copy,

Source

pub fn child_body_size(&self) -> usize

Return the size of the child type, according to the vector’s body header.

Source

pub fn child_body_type(&self) -> URID

Return the type of the child, according to the vector’s body header.

Source

pub fn as_slice(&self) -> &[T]

Return a slice containing all items in the vector.

No allocation is done; This method simply borrows the data of the vector.

Auto Trait Implementations§

§

impl<H, T> Freeze for ArrayAtomBody<H, T>
where H: Freeze, T: Freeze,

§

impl<H, T> RefUnwindSafe for ArrayAtomBody<H, T>

§

impl<H, T> Send for ArrayAtomBody<H, T>
where H: Send, T: Send,

§

impl<H, T> !Sized for ArrayAtomBody<H, T>

§

impl<H, T> Sync for ArrayAtomBody<H, T>
where H: Sync, T: Sync,

§

impl<H, T> Unpin for ArrayAtomBody<H, T>
where H: Unpin, T: Unpin,

§

impl<H, T> UnwindSafe for ArrayAtomBody<H, T>
where H: UnwindSafe, 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