Struct Object

Source
pub struct Object<Base> { /* private fields */ }

Implementations§

Source§

impl<Base> Object<Base>

Source

pub fn into_tx(self) -> Result<TxObject<Base>>

Start a transaction on this object, turning this object into a transaction object handle.

§Example

let obj = ObjectBuilder::new().build(12u32).unwrap();
let tx_obj = obj.into_tx().unwrap();
tx_obj.base_mut() += 1;
Source

pub fn as_tx(&self) -> Result<TxObject<Base>>

Start a transaction on this object, creating a new transaction object handle.

§Example

let obj = ObjectBuilder::new().build(12u32).unwrap();
let tx_obj = obj.as_tx().unwrap();
tx_obj.base_mut() += 1;
Source

pub fn with_tx<R>( &mut self, f: impl FnOnce(&mut TxObject<Base>) -> Result<R>, ) -> Result<R>

Perform a transaction on this object, within the provided closure.

§Example

let obj = ObjectBuilderrstarst::new().build(12u32).unwrap();
obj.with_tx(|tx| tx.base_mut() += 1).unwrap();
Source

pub unsafe fn as_mut(&self) -> Result<MutObject<Base>>

Create a new mutable object handle from this object.

§Safety

The caller must ensure that the underlying object is not changed outside of this mapping.

Source

pub unsafe fn into_mut(self) -> Result<MutObject<Base>>

Create a new mutable object handle from this object.

§Safety

The caller must ensure that the underlying object is not changed outside of this mapping.

Source

pub unsafe fn from_handle_unchecked(handle: ObjectHandle) -> Self

Source

pub fn from_handle(handle: ObjectHandle) -> Result<Self>

Source

pub fn into_handle(self) -> ObjectHandle

Source

pub unsafe fn cast<U>(self) -> Object<U>

Source

pub fn map(id: ObjID, flags: MapFlags) -> Result<Self>

Open a new object from its ID.

The provided map flags must contain at least READ, and for stable read maps, INDIRECT. For writes, add WRITE and PERSIST.

This function checks the underlying fingerprint of the base type against the stored value and fails on mismatch to ensure type safety.

Source

pub unsafe fn map_unchecked(id: ObjID, flags: MapFlags) -> Result<Self>

Open a new object from its ID without checking the underlying fingerprint.

§Safety

This function is unsafe because it does not check the underlying fingerprint of the base type against the stored value. Use with caution.

Source

pub fn id(&self) -> ObjID

Return the ID of the object.

Source

pub fn update(&mut self) -> Result<()>

Update the underlying mapping of the object. This invalidates all references to the object (hence why it takes &mut self).

Trait Implementations§

Source§

impl<T> AsRef<ObjectHandle> for Object<T>

Source§

fn as_ref(&self) -> &ObjectHandle

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl<B> Clone for Object<B>

Source§

fn clone(&self) -> Self

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<B> From<MutObject<B>> for Object<B>

Source§

fn from(mut_obj: MutObject<B>) -> Self

Converts to this type from the input type.
Source§

impl<T: Invariant, A: Allocator> From<Object<Vec<T, A>>> for VecObject<T, A>

Source§

fn from(value: Object<Vec<T, A>>) -> Self

Converts to this type from the input type.
Source§

impl<Base> RawObject for Object<Base>

Source§

fn handle(&self) -> &ObjectHandle

Get the underlying runtime handle for this object.
Source§

fn id(&self) -> ObjID

Get the object ID.
Source§

fn base_ptr<T>(&self) -> *const T

Get a const pointer to the object base.
Source§

fn base_mut_ptr<T>(&self) -> *mut T

Get a mut pointer to the object base.
Source§

fn meta_ptr(&self) -> *const MetaInfo

Get a const pointer to the object metadata.
Source§

fn meta_mut_ptr(&self) -> *mut MetaInfo

Get a mut pointer to the object metadata.
Source§

fn fote_ptr(&self, idx: usize) -> Option<*const FotEntry>

Get a const pointer to a given FOT entry.
Source§

fn fote_ptr_mut(&self, idx: usize) -> Option<*mut FotEntry>

Get a mut pointer to a given FOT entry.
Source§

fn lea(&self, offset: usize, _len: usize) -> Option<*const u8>

Get a const pointer to given range of the object.
Source§

fn lea_mut(&self, offset: usize, _len: usize) -> Option<*mut u8>

Get a mut pointer to given range of the object.
Source§

fn ptr_local(&self, ptr: *const u8) -> Option<usize>

If the pointer is local to this object, return the offset into the object. Otherwise, return None.
Source§

impl<Base: BaseType> TypedObject for Object<Base>

Source§

type Base = Base

The base type of this object.
Source§

fn base_ref(&self) -> Ref<'_, Self::Base>

Returns a resolved reference to the object’s base.
Source§

fn base(&self) -> &Self::Base

Source§

impl<Base> Send for Object<Base>

Source§

impl<Base> Sync for Object<Base>

Auto Trait Implementations§

§

impl<Base> Freeze for Object<Base>

§

impl<Base> !ObjSafe for Object<Base>

§

impl<Base> RefUnwindSafe for Object<Base>
where Base: RefUnwindSafe,

§

impl<Base> StoreCopy for Object<Base>
where Base: StoreCopy,

§

impl<Base> Unpin for Object<Base>

§

impl<Base> UnwindSafe for Object<Base>
where Base: RefUnwindSafe,

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.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

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

impl<T> WithSubscriber for T

§

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
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more