pub struct ObjectBuilder<Base: BaseType> { /* private fields */ }
Expand description
An object builder, for constructing objects using a builder API.
Implementations§
Source§impl<Base: BaseType> ObjectBuilder<Base>
impl<Base: BaseType> ObjectBuilder<Base>
Sourcepub fn new(spec: ObjectCreate) -> Self
pub fn new(spec: ObjectCreate) -> Self
Make a new object builder.
Sourcepub fn cast<U: BaseType>(self) -> ObjectBuilder<U>
pub fn cast<U: BaseType>(self) -> ObjectBuilder<U>
Cast the base type.
Sourcepub fn add_src(self, obj_src: ObjectSource) -> Self
pub fn add_src(self, obj_src: ObjectSource) -> Self
Add a Source Object that this new object will copy from.
Sourcepub fn add_tie(self, tie: CreateTieSpec) -> Self
pub fn add_tie(self, tie: CreateTieSpec) -> Self
Add a tie specification for this object creation.
Source§impl<Base: BaseType + StoreCopy> ObjectBuilder<Base>
impl<Base: BaseType + StoreCopy> ObjectBuilder<Base>
Source§impl<Base: BaseType> ObjectBuilder<Base>
impl<Base: BaseType> ObjectBuilder<Base>
Sourcepub fn build_inplace<F>(&self, ctor: F) -> Result<Object<Base>>
pub fn build_inplace<F>(&self, ctor: F) -> Result<Object<Base>>
Build an object using the provided constructor function.
The constructor should call the .write() method on the TxObject, and return the result.
§Example
let builder = ObjectBuilder::default();
let obj = builder.build_inplace(|tx| tx.write(42u32)).unwrap();
Sourcepub unsafe fn build_ctor<F>(&self, ctor: F) -> Result<Object<Base>>
pub unsafe fn build_ctor<F>(&self, ctor: F) -> Result<Object<Base>>
Build an object using the provided constructor function.
The constructor should call the .write() method on the TxObject or otherwise ensure that it is safe to call .assume_init on the underlying MaybeUninit.
§Safety
The caller must ensure that the base is initialized, see MaybeUninit::assume_init.
§Example
let builder = ObjectBuilder::default();
let obj = unsafe {
builder
.build_ctor(|tx| {
tx.write(42u32);
})
.unwrap()
};
Trait Implementations§
Source§impl<Base: Clone + BaseType> Clone for ObjectBuilder<Base>
impl<Base: Clone + BaseType> Clone for ObjectBuilder<Base>
Source§fn clone(&self) -> ObjectBuilder<Base>
fn clone(&self) -> ObjectBuilder<Base>
Returns a copy of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreAuto Trait Implementations§
impl<Base> Freeze for ObjectBuilder<Base>
impl<Base> !ObjSafe for ObjectBuilder<Base>
impl<Base> RefUnwindSafe for ObjectBuilder<Base>where
Base: RefUnwindSafe,
impl<Base> Send for ObjectBuilder<Base>where
Base: Send,
impl<Base> StoreCopy for ObjectBuilder<Base>where
Base: StoreCopy,
impl<Base> Sync for ObjectBuilder<Base>where
Base: Sync,
impl<Base> Unpin for ObjectBuilder<Base>where
Base: Unpin,
impl<Base> UnwindSafe for ObjectBuilder<Base>where
Base: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more