Skip to main content

Table

Struct Table 

Source
pub struct Table<T: 'static> { /* private fields */ }
Expand description

A C table that starts with uint32_t size: Anvil’s host table or a service’s. Its provider may be older than this crate, so its table may be shorter than T. Table keeps the pointer and the provider’s size and never makes a &T that reaches past them: the crate reads a field only when size covers it (the ANVIL_*_HAS macros of the C headers), and get hands out &T only for a table at least as long as T.

Implementations§

Source§

impl<T> Table<T>

Source

pub unsafe fn from_raw(ptr: *const T) -> Option<Self>

The table behind ptr; None for null. Only its first four bytes, the size, are read here.

§Safety

ptr is null or points to a table of T’s layout (or an older, shorter version of it) whose first field is u32 size, with at least size bytes readable, unchanged and valid for the process; T is plain data without interior mutability (a C table of size, values and function pointers), so that sharing it between threads is sound.

Source

pub fn size(&self) -> u32

The provider’s size: how many bytes of T its table has.

Source

pub fn as_ptr(&self) -> *const T

The table’s address.

Source

pub fn get(&self) -> Option<&'static T>

The whole table as T, when the provider’s is at least as long as T; None from an older provider, whose table is shorter.

Trait Implementations§

Source§

impl<T> Clone for Table<T>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<T> Copy for Table<T>

Source§

impl<T> Debug for Table<T>

Source§

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

Formats the value using the given formatter. Read more
Source§

impl<T> Send for Table<T>

Source§

impl<T> Sync for Table<T>

Auto Trait Implementations§

§

impl<T> Forget for Table<T>

§

impl<T> Freeze for Table<T>
where NonNull<T>: Freeze,

§

impl<T> Move for Table<T>

§

impl<T> RefUnwindSafe for Table<T>

§

impl<T> Unpin for Table<T>
where NonNull<T>: Unpin,

§

impl<T> UnsafeUnpin for Table<T>
where NonNull<T>: UnsafeUnpin,

§

impl<T> UnwindSafe for Table<T>
where NonNull<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> 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> 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 = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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.