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.
pub fn named(self, name: impl ToString) -> Self
Source§impl<Base: BaseType + StoreCopy> ObjectBuilder<Base>
impl<Base: BaseType + StoreCopy> ObjectBuilder<Base>
Sourcepub fn build(&self, base: Base) -> Result<Object<Base>>
pub fn build(&self, base: Base) -> Result<Object<Base>>
Build an object using the provided base value.
§Panics
This function may panic if the default permissions dont contain READ and WRITE.
If your usecase requires that the default permissions for an object can’t
contain those flags, please look at the twizzler_security::SecureBuilderExt trait.
§Example
let builder = ObjectBuilder::default();
let obj = builder.build(42u32).unwrap();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>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more