Struct Block

Source
pub struct Block<T, Kind> { /* private fields */ }
Expand description

Points to an index in the VMO and reads it according to the bytes in it.

Implementations§

Source§

impl<T: Deref<Target = Q>, Q: ReadBytes, K: BlockKind> Block<T, K>

Source

pub fn index(&self) -> BlockIndex

Returns index of the block in the vmo.

Source

pub fn order(&self) -> u8

Returns the order of the block.

Source

pub fn block_type(&self) -> Option<BlockType>

Returns the type of a block.

Source

pub fn block_type_raw(&self) -> u8

Returns the type of a block.

Source§

impl<T: Deref<Target = Q>, Q: ReadBytes> Block<T, Unknown>

Source

pub fn cast<K: BlockKind>(self) -> Option<Block<T, K>>

Source

pub fn cast_unchecked<K: BlockKind>(self) -> Block<T, K>

Source§

impl<T: Deref<Target = Q>, Q: ReadBytes> Block<T, Array<Unknown>>

Source

pub fn cast_array<K: ArraySlotKind>(self) -> Option<Block<T, Array<K>>>

Source

pub fn cast_array_unchecked<K: BlockKind>(self) -> Block<T, Array<K>>

Source§

impl<T: Deref<Target = Q>, Q: ReadBytes> Block<T, Header>

Source

pub fn magic_number(&self) -> u32

Returns the magic number in a HEADER block.

Source

pub fn version(&self) -> u32

Returns the version of a HEADER block.

Source

pub fn generation_count(&self) -> u64

Returns the generation count of a HEADER block.

Source

pub fn vmo_size(&self) -> Result<Option<u32>, Error>

Returns the size of the part of the VMO that is currently allocated. The size is saved in a field in the HEADER block.

Source

pub fn is_locked(&self) -> bool

True if the header is locked, false otherwise.

Source§

impl<T: Deref<Target = Q>, Q: ReadBytes> Block<T, Double>

Source

pub fn value(&self) -> f64

Gets the double value of a DOUBLE_VALUE block.

Source§

impl<T: Deref<Target = Q>, Q: ReadBytes> Block<T, Int>

Source

pub fn value(&self) -> i64

Gets the value of an INT_VALUE block.

Source§

impl<T: Deref<Target = Q>, Q: ReadBytes> Block<T, Uint>

Source

pub fn value(&self) -> u64

Gets the unsigned value of a UINT_VALUE block.

Source§

impl<T: Deref<Target = Q>, Q: ReadBytes> Block<T, Bool>

Source

pub fn value(&self) -> bool

Gets the bool values of a BOOL_VALUE block.

Source§

impl<T: Deref<Target = Q>, Q: ReadBytes> Block<T, Buffer>

Source

pub fn extent_index(&self) -> BlockIndex

Gets the index of the EXTENT of the PROPERTY block.

Source

pub fn total_length(&self) -> usize

Gets the total length of a PROPERTY or STRING_REFERERENCE block.

Source

pub fn format(&self) -> Option<PropertyFormat>

Gets the flags of a PROPERTY block.

Source

pub fn format_raw(&self) -> u8

Gets the flags of a PROPERTY block.

Source§

impl<'a, T: Deref<Target = Q>, Q: ReadBytes + 'a> Block<T, StringRef>

Source

pub fn total_length(&self) -> usize

Gets the total length of a PROPERTY or STRING_REFERERENCE block.

Source

pub fn next_extent(&self) -> BlockIndex

Returns the next EXTENT in an EXTENT chain.

Source

pub fn reference_count(&self) -> u32

Returns the current reference count of a string reference.

Source

pub fn inline_data(&'a self) -> Result<&'a [u8], Error>

Read the inline portion of a STRING_REFERENCE

Source§

impl<'a, T: Deref<Target = Q>, Q: ReadBytes + 'a> Block<T, Extent>

Source

pub fn next_extent(&self) -> BlockIndex

Returns the next EXTENT in an EXTENT chain.

Source

pub fn contents(&'a self) -> Result<&'a [u8], Error>

Returns the payload bytes value of an EXTENT block.

Source§

impl<T: Deref<Target = Q>, Q: ReadBytes, S: ArraySlotKind> Block<T, Array<S>>

Source

pub fn format(&self) -> Option<ArrayFormat>

Gets the format of an ARRAY_VALUE block.

Source

pub fn slots(&self) -> usize

Gets the number of slots in an ARRAY_VALUE block.

Source

pub fn capacity(&self) -> Option<usize>

Get the array capacity size for the given |order|.

Source

pub fn entry_type(&self) -> Option<BlockType>

Gets the type of each slot in an ARRAY_VALUE block.

Source

pub fn entry_type_raw(&self) -> u8

Gets the type of each slot in an ARRAY_VALUE block.

Source

pub fn entry_type_size(&self) -> Option<usize>

Source§

impl<T: Deref<Target = Q>, Q: ReadBytes> Block<T, Array<StringRef>>

Source

pub fn get_string_index_at(&self, slot_index: usize) -> Option<BlockIndex>

Source§

impl<T: Deref<Target = Q>, Q: ReadBytes> Block<T, Array<Int>>

Source

pub fn get(&self, slot_index: usize) -> Option<i64>

Gets the value of an int ARRAY_VALUE slot.

Source§

impl<T: Deref<Target = Q>, Q: ReadBytes> Block<T, Array<Double>>

Source

pub fn get(&self, slot_index: usize) -> Option<f64>

Gets the value of a double ARRAY_VALUE slot.

Source§

impl<T: Deref<Target = Q>, Q: ReadBytes> Block<T, Array<Uint>>

Source

pub fn get(&self, slot_index: usize) -> Option<u64>

Gets the value of a uint ARRAY_VALUE slot.

Source§

impl<T: Deref<Target = Q>, Q: ReadBytes> Block<T, Link>

Source

pub fn content_index(&self) -> BlockIndex

Gets the index of the content of this LINK_VALUE block.

Gets the node disposition of a LINK_VALUE block.

Source§

impl<T: Deref<Target = Q>, Q: ReadBytes, K: ValueBlockKind> Block<T, K>

Source

pub fn name_index(&self) -> BlockIndex

Gets the NAME block index of a *_VALUE block.

Source

pub fn parent_index(&self) -> BlockIndex

Get the parent block index of a *_VALUE block.

Source§

impl<T: Deref<Target = Q>, Q: ReadBytes> Block<T, Node>

Source

pub fn child_count(&self) -> u64

Get the child count of a NODE_VALUE block.

Source§

impl<T: Deref<Target = Q>, Q: ReadBytes> Block<T, Tombstone>

Source

pub fn child_count(&self) -> u64

Get the child count of a TOMBSTONE block.

Source§

impl<T: Deref<Target = Q>, Q: ReadBytes> Block<T, Free>

Source

pub fn free_next_index(&self) -> BlockIndex

Get next free block

Source§

impl<'a, T: Deref<Target = Q>, Q: ReadBytes + 'a> Block<T, Name>

Source

pub fn length(&self) -> usize

Get the length of the name of a NAME block

Source

pub fn contents(&'a self) -> Result<&'a str, Error>

Returns the contents of a NAME block.

Source§

impl<T: Deref<Target = Q> + DerefMut<Target = Q>, Q: WriteBytes + ReadBytes, K: BlockKind> Block<T, K>

Source

pub fn become_free(self, next: BlockIndex) -> Block<T, Free>

Converts a block to a FREE block

Source§

impl<T: Deref<Target = Q> + DerefMut<Target = Q>, Q: WriteBytes + ReadBytes, K: BlockKind> Block<T, K>

Source

pub fn set_order(&mut self, order: u8) -> Result<(), Error>

Set the order of the block.

Source§

impl<T: Deref<Target = Q> + DerefMut<Target = Q>, Q: WriteBytes + ReadBytes> Block<T, Free>

Source

pub fn free( container: T, index: BlockIndex, order: u8, next_free: BlockIndex, ) -> Result<Block<T, Free>, Error>

Initializes an empty free block.

Source

pub fn become_reserved(self) -> Block<T, Reserved>

Converts a FREE block to a RESERVED block

Source

pub fn set_free_next_index(&mut self, next_free: BlockIndex)

Set the next free block.

Source§

impl<T: Deref<Target = Q> + DerefMut<Target = Q>, Q: WriteBytes + ReadBytes> Block<T, Reserved>

Source

pub fn become_header(self, size: usize) -> Result<Block<T, Header>, Error>

Initializes a HEADER block.

Source

pub fn become_extent(self, next_extent_index: BlockIndex) -> Block<T, Extent>

Converts a block to an EXTENT block.

Source

pub fn become_double_value( self, value: f64, name_index: BlockIndex, parent_index: BlockIndex, ) -> Block<T, Double>

Converts a RESERVED block into a DOUBLE_VALUE block.

Source

pub fn become_int_value( self, value: i64, name_index: BlockIndex, parent_index: BlockIndex, ) -> Block<T, Int>

Converts a RESERVED block into an INT_VALUE block.

Source

pub fn become_uint_value( self, value: u64, name_index: BlockIndex, parent_index: BlockIndex, ) -> Block<T, Uint>

Converts a RESERVED block into a UINT_VALUE block.

Source

pub fn become_bool_value( self, value: bool, name_index: BlockIndex, parent_index: BlockIndex, ) -> Block<T, Bool>

Converts a RESERVED block into a BOOL_VALUE block.

Source

pub fn become_node( self, name_index: BlockIndex, parent_index: BlockIndex, ) -> Block<T, Node>

Initializes a NODE_VALUE block.

Source

pub fn become_property( self, name_index: BlockIndex, parent_index: BlockIndex, format: PropertyFormat, ) -> Block<T, Buffer>

Converts a *_VALUE block into a BUFFER_VALUE block.

Source

pub fn become_string_reference(self) -> Block<T, StringRef>

Initializes a STRING_REFERENCE block. Everything is set except for the payload string and total length.

Source

pub fn become_name(self, name: &str) -> Block<T, Name>

Creates a NAME block.

Creates a LINK block.

Source

pub fn become_array_value<S: ArraySlotKind>( self, slots: usize, format: ArrayFormat, name_index: BlockIndex, parent_index: BlockIndex, ) -> Result<Block<T, Array<S>>, Error>

Converts a block to an *_ARRAY_VALUE block

Source§

impl<T: Deref<Target = Q> + DerefMut<Target = Q>, Q: WriteBytes + ReadBytes> Block<T, Header>

Source

pub fn set_vmo_size(&mut self, size: u32) -> Result<(), Error>

Set the size of the part of the VMO that is currently allocated. The size is saved in a field in the HEADER block.

Source

pub fn freeze(&mut self) -> u64

Freeze the HEADER, indicating a VMO is frozen.

Source

pub fn thaw(&mut self, gen: u64)

Thaw the HEADER, indicating a VMO is Live again.

Source

pub fn lock(&mut self)

Lock a HEADER block

Source

pub fn unlock(&mut self)

Unlock a HEADER block

Source§

impl<T: Deref<Target = Q> + DerefMut<Target = Q>, Q: WriteBytes + ReadBytes> Block<T, Node>

Source

pub fn become_tombstone(self) -> Block<T, Tombstone>

Initializes a TOMBSTONE block.

Source

pub fn set_child_count(&mut self, count: u64)

Set the child count of a NODE_VALUE block.

Source§

impl<T: Deref<Target = Q> + DerefMut<Target = Q>, Q: WriteBytes + ReadBytes, S: ArraySlotKind> Block<T, Array<S>>

Source

pub fn clear(&mut self, start_slot_index: usize)

Sets all values of the array to zero starting on start_slot_index (inclusive).

Source§

impl<T: Deref<Target = Q> + DerefMut<Target = Q>, Q: WriteBytes + ReadBytes> Block<T, Array<StringRef>>

Source

pub fn set_string_slot(&mut self, slot_index: usize, string_index: BlockIndex)

Sets the value of a string ARRAY_VALUE block.

Source§

impl<T: Deref<Target = Q> + DerefMut<Target = Q>, Q: WriteBytes + ReadBytes> Block<T, Array<Int>>

Source

pub fn set(&mut self, slot_index: usize, value: i64)

Sets the value of an int ARRAY_VALUE block.

Source§

impl<T: Deref<Target = Q> + DerefMut<Target = Q>, Q: WriteBytes + ReadBytes> Block<T, Array<Double>>

Source

pub fn set(&mut self, slot_index: usize, value: f64)

Sets the value of a double ARRAY_VALUE block.

Source§

impl<T: Deref<Target = Q> + DerefMut<Target = Q>, Q: WriteBytes + ReadBytes> Block<T, Array<Uint>>

Source

pub fn set(&mut self, slot_index: usize, value: u64)

Sets the value of a uint ARRAY_VALUE block.

Source§

impl<T: Deref<Target = Q> + DerefMut<Target = Q>, Q: WriteBytes + ReadBytes> Block<T, Extent>

Source

pub fn set_next_index(&mut self, next_extent_index: BlockIndex)

Sets the index of the next EXTENT in the chain.

Source

pub fn set_contents(&mut self, value: &[u8]) -> usize

Set the payload of an EXTENT block. The number of bytes written will be returned.

Source§

impl<T: Deref<Target = Q> + DerefMut<Target = Q>, Q: WriteBytes + ReadBytes> Block<T, StringRef>

Source

pub fn set_next_index(&mut self, next_extent_index: BlockIndex)

Sets the index of the next EXTENT in the chain.

Source

pub fn set_total_length(&mut self, length: u32)

Sets the total length of a BUFFER_VALUE or STRING_REFERENCE block.

Source

pub fn increment_ref_count(&mut self) -> Result<(), Error>

Increment the reference count by 1.

Source

pub fn decrement_ref_count(&mut self) -> Result<(), Error>

Decrement the reference count by 1.

Source

pub fn write_inline(&mut self, value: &[u8]) -> usize

Write the portion of the string that fits into the STRING_REFERENCE block, as well as write the total length of value to the block. Returns the number of bytes written.

Source§

impl<T: Deref<Target = Q> + DerefMut<Target = Q>, Q: WriteBytes + ReadBytes> Block<T, Double>

Source

pub fn set(&mut self, value: f64)

Sets the value of a DOUBLE_VALUE block.

Source§

impl<T: Deref<Target = Q> + DerefMut<Target = Q>, Q: WriteBytes + ReadBytes> Block<T, Int>

Source

pub fn set(&mut self, value: i64)

Sets the value of a INT_VALUE block.

Source§

impl<T: Deref<Target = Q> + DerefMut<Target = Q>, Q: WriteBytes + ReadBytes> Block<T, Uint>

Source

pub fn set(&mut self, value: u64)

Sets the value of a UINT_VALUE block.

Source§

impl<T: Deref<Target = Q> + DerefMut<Target = Q>, Q: WriteBytes + ReadBytes> Block<T, Bool>

Source

pub fn set(&mut self, value: bool)

Sets the value of a BOOL_VALUE block.

Source§

impl<T: Deref<Target = Q> + DerefMut<Target = Q>, Q: WriteBytes + ReadBytes> Block<T, Buffer>

Source

pub fn set_total_length(&mut self, length: u32)

Sets the total length of a BUFFER_VALUE block.

Source

pub fn set_extent_index(&mut self, index: BlockIndex)

Sets the index of the EXTENT of a BUFFER_VALUE block.

Source§

impl<T: Deref<Target = Q> + DerefMut<Target = Q>, Q: WriteBytes + ReadBytes> Block<T, Tombstone>

Source

pub fn set_child_count(&mut self, count: u64)

Set the child count of a NODE_VALUE block.

Source§

impl<T: Deref<Target = Q> + DerefMut<Target = Q>, Q: WriteBytes + ReadBytes, K: ValueBlockKind> Block<T, K>

Source

pub fn set_parent(&mut self, new_parent_index: BlockIndex)

Trait Implementations§

Source§

impl<T: Clone, Kind: Clone> Clone for Block<T, Kind>

Source§

fn clone(&self) -> Block<T, Kind>

Returns a copy 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, Kind: Debug> Debug for Block<T, Kind>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<T, Kind> Freeze for Block<T, Kind>
where T: Freeze,

§

impl<T, Kind> RefUnwindSafe for Block<T, Kind>
where T: RefUnwindSafe, Kind: RefUnwindSafe,

§

impl<T, Kind> Send for Block<T, Kind>
where T: Send, Kind: Send,

§

impl<T, Kind> Sync for Block<T, Kind>
where T: Sync, Kind: Sync,

§

impl<T, Kind> Unpin for Block<T, Kind>
where T: Unpin, Kind: Unpin,

§

impl<T, Kind> UnwindSafe for Block<T, Kind>
where T: UnwindSafe, Kind: 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, dst: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
§

impl<T, D> Encode<Ambiguous1, D> for T
where D: ResourceDialect,

§

unsafe fn encode( self, _encoder: &mut Encoder<'_, D>, _offset: usize, _depth: Depth, ) -> Result<(), Error>

Encodes the object into the encoder’s buffers. Any handles stored in the object are swapped for Handle::INVALID. Read more
§

impl<T, D> Encode<Ambiguous2, D> for T
where D: ResourceDialect,

§

unsafe fn encode( self, _encoder: &mut Encoder<'_, D>, _offset: usize, _depth: Depth, ) -> Result<(), Error>

Encodes the object into the encoder’s buffers. Any handles stored in the object are swapped for Handle::INVALID. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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
§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

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

Initializes a with the given initializer. Read more
§

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

Dereferences the given pointer. Read more
§

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

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
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.