pub struct Owner<S = UnsyncStorage>(/* private fields */)
where
S: AnyStorage + 'static;
Expand description
Owner: Handles dropping generational boxes. The owner acts like a runtime lifetime guard. Any states that you create with an owner will be dropped when that owner is dropped.
Implementations§
§impl<S> Owner<S>where
S: AnyStorage,
impl<S> Owner<S>where
S: AnyStorage,
pub fn insert<T>(&self, value: T) -> GenerationalBox<T, S>where
T: 'static,
S: Storage<T>,
pub fn insert<T>(&self, value: T) -> GenerationalBox<T, S>where
T: 'static,
S: Storage<T>,
Insert a value into the store. The value will be dropped when the owner is dropped.
pub fn insert_rc<T>(&self, value: T) -> GenerationalBox<T, S>where
T: 'static,
S: Storage<T>,
pub fn insert_rc<T>(&self, value: T) -> GenerationalBox<T, S>where
T: 'static,
S: Storage<T>,
Create a new reference counted box. The box will be dropped when all references are dropped.
pub fn insert_rc_with_caller<T>(
&self,
value: T,
caller: &'static Location<'static>,
) -> GenerationalBox<T, S>where
T: 'static,
S: Storage<T>,
pub fn insert_rc_with_caller<T>(
&self,
value: T,
caller: &'static Location<'static>,
) -> GenerationalBox<T, S>where
T: 'static,
S: Storage<T>,
Insert a value into the store with a specific location blamed for creating the value. The value will be dropped when the owner is dropped.
pub fn insert_with_caller<T>(
&self,
value: T,
caller: &'static Location<'static>,
) -> GenerationalBox<T, S>where
T: 'static,
S: Storage<T>,
pub fn insert_with_caller<T>(
&self,
value: T,
caller: &'static Location<'static>,
) -> GenerationalBox<T, S>where
T: 'static,
S: Storage<T>,
Insert a value into the store with a specific location blamed for creating the value. The value will be dropped when the owner is dropped.
pub fn insert_reference<T>(
&self,
other: GenerationalBox<T, S>,
) -> Result<GenerationalBox<T, S>, BorrowError>where
T: 'static,
S: Storage<T>,
pub fn insert_reference<T>(
&self,
other: GenerationalBox<T, S>,
) -> Result<GenerationalBox<T, S>, BorrowError>where
T: 'static,
S: Storage<T>,
Create a new reference to an existing box. The reference will be dropped when the owner is dropped.
This method may return an error if the other box is no longer valid or it is already borrowed mutably.
Trait Implementations§
§impl<S> Clone for Owner<S>where
S: AnyStorage,
impl<S> Clone for Owner<S>where
S: AnyStorage,
Auto Trait Implementations§
impl<S> Freeze for Owner<S>
impl<S = UnsyncStorage> !RefUnwindSafe for Owner<S>
impl<S> Send for Owner<S>where
S: Sync,
impl<S> Sync for Owner<S>where
S: Sync,
impl<S> Unpin for Owner<S>
impl<S = UnsyncStorage> !UnwindSafe for Owner<S>
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
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
. Box<dyn Any>
can
then be further downcast
into Box<ConcreteType>
where ConcreteType
implements Trait
.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.§impl<T> DowncastSync for T
impl<T> DowncastSync for T
§impl<T> InitializeFromFunction<T> for T
impl<T> InitializeFromFunction<T> for T
§fn initialize_from_function(f: fn() -> T) -> T
fn initialize_from_function(f: fn() -> T) -> T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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§impl<T> NoneValue for Twhere
T: Default,
impl<T> NoneValue for Twhere
T: Default,
type NoneType = T
§fn null_value() -> T
fn null_value() -> T
§impl<T> Pointable for T
impl<T> Pointable for T
source§impl<R, P> ReadPrimitive<R> for P
impl<R, P> ReadPrimitive<R> for P
source§fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
ReadEndian::read_from_little_endian()
.