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>
impl<P: ?Sized + 'static> PortCell<P>
pub fn new(container: &Rc<Container>, key: &'static str) -> PortCell<P>
Sourcepub fn get(&self) -> Rc<P>
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.
Sourcepub fn with<R>(&self, f: impl FnOnce(&P) -> R) -> R
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.
Sourcepub fn try_get(&self) -> Result<Rc<P>, ContainerError>
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>
impl<P> UnsafeUnpin for PortCell<P>
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