VTableIndirect

Struct VTableIndirect 

Source
pub struct VTableIndirect {
    pub display: Option<unsafe fn(OxPtrConst, &mut Formatter<'_>) -> Option<Result>>,
    pub debug: Option<unsafe fn(OxPtrConst, &mut Formatter<'_>) -> Option<Result>>,
    pub hash: Option<unsafe fn(OxPtrConst, &mut HashProxy<'_>) -> Option<()>>,
    pub invariants: Option<unsafe fn(OxPtrConst) -> Option<Result<(), String>>>,
    pub parse: Option<unsafe fn(&str, OxPtrMut) -> Option<Result<(), ParseError>>>,
    pub parse_bytes: Option<unsafe fn(&[u8], OxPtrMut) -> Option<Result<(), ParseError>>>,
    pub try_from: Option<unsafe fn(OxPtrMut, &'static Shape, PtrConst) -> Option<Result<(), String>>>,
    pub try_into_inner: Option<unsafe fn(OxPtrMut) -> Option<Result<PtrMut, String>>>,
    pub try_borrow_inner: Option<unsafe fn(OxPtrConst) -> Option<Result<PtrMut, String>>>,
    pub partial_eq: Option<unsafe fn(OxPtrConst, OxPtrConst) -> Option<bool>>,
    pub partial_cmp: Option<unsafe fn(OxPtrConst, OxPtrConst) -> Option<Option<Ordering>>>,
    pub cmp: Option<unsafe fn(OxPtrConst, OxPtrConst) -> Option<Ordering>>,
}
Expand description

VTable for generic containers with runtime trait resolution.

Uses OxPtrConst/OxPtrMut as receivers to access inner type’s shape at runtime. Used for Vec<T>, Option<T>, Arc<T>, etc.

Returns Option to indicate whether the operation is supported (the inner type may not implement the required trait).

§Per-type operations

Note that drop_in_place, default_in_place, and clone_into are NOT in this struct. These operations must be monomorphized per-type and live in TypeOps on the crate::Shape. This allows vtables to be shared across generic instantiations (e.g., one vtable for all Vec<T>).

§Safety

All function pointers are unsafe fn because they operate on raw pointers. Callers must ensure:

  • The pointer points to a valid instance of the expected type
  • The pointer has the correct alignment for the type
  • For mutable operations, the caller has exclusive access to the data
  • The lifetime of the data extends for the duration of the operation

Fields§

§display: Option<unsafe fn(OxPtrConst, &mut Formatter<'_>) -> Option<Result>>

Display function - formats value using Display trait.

§debug: Option<unsafe fn(OxPtrConst, &mut Formatter<'_>) -> Option<Result>>

Debug function - formats value using Debug trait.

§hash: Option<unsafe fn(OxPtrConst, &mut HashProxy<'_>) -> Option<()>>

Hash function - hashes value using Hash trait via HashProxy.

§invariants: Option<unsafe fn(OxPtrConst) -> Option<Result<(), String>>>

Invariants function - checks type invariants.

§parse: Option<unsafe fn(&str, OxPtrMut) -> Option<Result<(), ParseError>>>

Parse function - parses value from string into destination.

§parse_bytes: Option<unsafe fn(&[u8], OxPtrMut) -> Option<Result<(), ParseError>>>

Parse bytes function - parses value from byte slice into destination. Used for binary formats where types have a more efficient representation.

§try_from: Option<unsafe fn(OxPtrMut, &'static Shape, PtrConst) -> Option<Result<(), String>>>

Try from function - converts from another value type. Arguments: (dst, src_shape, src_ptr)

§try_into_inner: Option<unsafe fn(OxPtrMut) -> Option<Result<PtrMut, String>>>

Try into inner function - extracts inner value (consuming).

§try_borrow_inner: Option<unsafe fn(OxPtrConst) -> Option<Result<PtrMut, String>>>

Try borrow inner function - borrows inner value.

§partial_eq: Option<unsafe fn(OxPtrConst, OxPtrConst) -> Option<bool>>

PartialEq function - tests equality with another value.

§partial_cmp: Option<unsafe fn(OxPtrConst, OxPtrConst) -> Option<Option<Ordering>>>

PartialOrd function - compares with another value.

§cmp: Option<unsafe fn(OxPtrConst, OxPtrConst) -> Option<Ordering>>

Ord function - total ordering comparison.

Implementations§

Source§

impl VTableIndirect

Source

pub const EMPTY: Self

An empty VTableIndirect with all fields set to None.

Source

pub const fn empty() -> Self

Returns an empty VTableIndirect with all fields set to None.

Trait Implementations§

Source§

impl Clone for VTableIndirect

Source§

fn clone(&self) -> VTableIndirect

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 Default for VTableIndirect

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl From<&'static VTableIndirect> for VTableErased

Source§

fn from(vt: &'static VTableIndirect) -> Self

Converts to this type from the input type.
Source§

impl Copy for VTableIndirect

Auto Trait Implementations§

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 = 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.