pub struct AttachGuard { /* private fields */ }Expand description
Owns an attached resource for the duration of one phase
activation. Drop emits resource.detach and, when the
entry’s refcount has fully drained, schedules an async
close() (and emits resource.close.* events around it).
Holding the guard keeps the resource alive; releasing it lets the pool tear down the resource if no other shells reference it.
Implements Debug so test helpers like
Result::expect_err accept it as the success type when
the error path is the one under test.
Implementations§
Source§impl AttachGuard
impl AttachGuard
Sourcepub fn resource(&self) -> Arc<dyn SharedResource> ⓘ
pub fn resource(&self) -> Arc<dyn SharedResource> ⓘ
Borrow the underlying shared resource. The guard
retains ownership; the Arc clone is cheap.
Sourcepub fn key(&self) -> &ResourceKey
pub fn key(&self) -> &ResourceKey
Resource key for the attached entry. Useful for log correlation in adapter shells.
Sourcepub async fn detach(self) -> Result<(), String>
pub async fn detach(self) -> Result<(), String>
Explicit detach. Calling this drains the refcount
and (if it hits zero) awaits the resource’s
close() synchronously, so the caller observes
teardown completion at this point. The guard’s
Drop falls back to a best-effort spawn when
detach() wasn’t called explicitly.
Trait Implementations§
Source§impl Debug for AttachGuard
impl Debug for AttachGuard
Source§impl Drop for AttachGuard
impl Drop for AttachGuard
Auto Trait Implementations§
impl !RefUnwindSafe for AttachGuard
impl !UnwindSafe for AttachGuard
impl Freeze for AttachGuard
impl Send for AttachGuard
impl Sync for AttachGuard
impl Unpin for AttachGuard
impl UnsafeUnpin for AttachGuard
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§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