Skip to main content

TypedObject

Struct TypedObject 

Source
#[repr(C)]
pub struct TypedObject { pub schema_id: u32, pub ref_count: u32, }
Expand description

A typed object with fixed field layout for O(1) access.

This struct uses #[repr(C)] to ensure predictable memory layout. Fields are stored inline after the header, accessed by byte offset.

Fields§

§schema_id: u32

Schema ID for runtime type checking

§ref_count: u32

Reference count for garbage collection

Implementations§

Source§

impl TypedObject

Source

pub fn alloc(schema: &TypeSchema) -> *mut TypedObject

Allocate a new typed object for the given schema.

Returns a pointer to the newly allocated object, or null on failure. The object is zero-initialized.

§Safety

Caller must ensure the returned pointer is eventually freed via dealloc_typed_object.

Source

pub fn alloc_raw(schema_id: SchemaId, data_size: usize) -> *mut TypedObject

Allocate a new typed object by schema ID and data size.

This is a lower-level allocation that doesn’t require a schema reference, useful when the schema is not available but the ID and size are known.

Source

pub fn inc_ref(&mut self)

Increment reference count.

Source

pub fn dec_ref(&mut self) -> bool

Decrement reference count. Returns true if object should be freed.

Source§

impl TypedObject

Source

pub unsafe fn get_field(&self, offset: usize) -> u64

Get a field value at the given byte offset.

§Safety

Caller must ensure:

  • offset is valid for this object’s schema
  • offset is 8-byte aligned
  • The object is properly initialized
Source

pub unsafe fn set_field(&mut self, offset: usize, value: u64)

Set a field value at the given byte offset.

§Safety

Caller must ensure:

  • offset is valid for this object’s schema
  • offset is 8-byte aligned
  • The object is properly initialized
Source

pub unsafe fn get_field_f64(&self, offset: usize) -> f64

Get a field value as f64 at the given byte offset.

Source

pub unsafe fn set_field_f64(&mut self, offset: usize, value: f64)

Set a field value as f64 at the given byte offset.

Source

pub unsafe fn get_field_i64(&self, offset: usize) -> i64

Get a field value as i64 at the given byte offset.

Source

pub unsafe fn set_field_i64(&mut self, offset: usize, value: i64)

Set a field value as i64 at the given byte offset.

Source

pub unsafe fn get_field_bool(&self, offset: usize) -> bool

Get a field value as bool at the given byte offset.

Source

pub unsafe fn set_field_bool(&mut self, offset: usize, value: bool)

Set a field value as bool at the given byte offset.

Source§

impl TypedObject

Source

pub fn data_ptr(&self) -> *const u8

Get a pointer to the field data area.

Source

pub fn data_ptr_mut(&mut self) -> *mut u8

Get a mutable pointer to the field data area.

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> 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<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

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> Allocation for T
where T: RefUnwindSafe + Send + Sync,