Shared

Struct Shared 

Source
pub struct Shared<S: ?Sized + IShared> { /* private fields */ }
Expand description

A pointer to a shared instance from the service container.

Implementations§

Source§

impl<S: ?Sized + IShared> Shared<S>

Source

pub fn new(inner: S::Pointer) -> Self

Creates a shared instance from the inner smart pointer.

Source

pub fn into_inner(self) -> S::Pointer

Returns the inner smart pointer of the shared instance.

Source

pub fn inner(&self) -> &S::Pointer

Returns a reference to the inner smart pointer.

Source

pub fn inner_mut(&mut self) -> &mut S::Pointer

Returns a reference to the inner smart pointer.

Source

pub fn is(&self, other: &Self) -> bool

Returns true if two shared instances point to the same instance.

Only compares the pointers, not the contents of the shared instances, and is therefore always cheap.

Source

pub fn access<U, F>(&self, f: F) -> U
where S::Pointer: IAccess, F: FnOnce(Poisoning<&<S::Pointer as IAccess>::Target>) -> U,

Get access to the shared instance through a closure.

Source

pub fn try_access<U, F>(&self, f: F) -> Option<U>
where S::Pointer: IAccess, F: FnOnce(Poisoning<&<S::Pointer as IAccess>::Target>) -> U,

Get access to the shared instance through a closure.

Source

pub fn access_mut<U, F>(&self, f: F) -> U
where S::Pointer: IAccessMut, F: FnOnce(Poisoning<&mut <S::Pointer as IAccess>::Target>) -> U,

Get access to the shared instance through a closure.

Source

pub fn try_access_mut<U, F>(&self, f: F) -> Option<U>
where S::Pointer: IAccessMut, F: FnOnce(Poisoning<&mut <S::Pointer as IAccess>::Target>) -> U,

Get access to the shared instance through a closure.

Trait Implementations§

Source§

impl<S: ?Sized + IShared> Clone for Shared<S>

Source§

fn clone(&self) -> Self

Clones the pointer to the shared instance.

Only increases the reference count, so this is very cheap. See Rc::clone and Arc::clone.

1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<S: ?Sized + IShared> Debug for Shared<S>
where S::Pointer: Debug,

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<S: ?Sized + IShared> Deref for Shared<S>
where S::Pointer: Deref,

Source§

type Target = <<S as IShared>::Pointer as Deref>::Target

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Self::Target

Dereferences the value.

Auto Trait Implementations§

§

impl<S> Freeze for Shared<S>
where <S as IShared>::Pointer: Freeze, S: ?Sized,

§

impl<S> RefUnwindSafe for Shared<S>
where <S as IShared>::Pointer: RefUnwindSafe, S: ?Sized,

§

impl<S> Send for Shared<S>
where <S as IShared>::Pointer: Send, S: ?Sized,

§

impl<S> Sync for Shared<S>
where <S as IShared>::Pointer: Sync, S: ?Sized,

§

impl<S> Unpin for Shared<S>
where <S as IShared>::Pointer: Unpin, S: ?Sized,

§

impl<S> UnwindSafe for Shared<S>
where <S as IShared>::Pointer: UnwindSafe, S: ?Sized,

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.

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<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
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.