Skip to main content

PortCell

Struct PortCell 

Source
pub struct PortCell<P: ?Sized + 'static> { /* private fields */ }
Expand description

A handle on the port P bound under a key. Holds the container weakly, so a container that owns, through an area or a handler, a value holding this cell is not kept alive by it.

Implementations§

Source§

impl<P: ?Sized + 'static> PortCell<P>

Source

pub fn new(container: &Rc<Container>, key: &'static str) -> PortCell<P>

Source

pub fn key(&self) -> &'static str

The port’s key.

Source

pub fn get(&self) -> Rc<P>

What the container binds under the key now. Panics, naming the key, when the container is gone or the key cannot be resolved: a provider binds every port its seam owns, so either is a configuration error.

Source

pub fn with<R>(&self, f: impl FnOnce(&P) -> R) -> R

Calls f with what the container binds under the key now; the hot path of a generated proxy. With nothing rebound since the last call it reads one counter and borrows the cache: no reference counting. Panics as PortCell::get does.

Source

pub fn try_get(&self) -> Result<Rc<P>, ContainerError>

As PortCell::get, with the failure returned instead.

Auto Trait Implementations§

§

impl<P> !Freeze for PortCell<P>

§

impl<P> !RefUnwindSafe for PortCell<P>

§

impl<P> !Send for PortCell<P>

§

impl<P> !Sync for PortCell<P>

§

impl<P> !UnwindSafe for PortCell<P>

§

impl<P> Forget for PortCell<P>
where P: ?Sized,

§

impl<P> Move for PortCell<P>
where P: ?Sized,

§

impl<P> Unpin for PortCell<P>
where RefCell<Option<Cached<P>>>: Unpin, P: ?Sized,

§

impl<P> UnsafeUnpin for PortCell<P>
where RefCell<Option<Cached<P>>>: UnsafeUnpin, P: ?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> 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<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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.