pub struct CapabilityLease<'scope, K: ScopeKind> { /* private fields */ }Expand description
Borrowed capability access tied to one typed scope owner.
A lease cannot be returned after its owner is dropped:
ⓘ
use a3s_code_core::capability::{CapabilityLease, CapabilityScope, Run};
fn escape<'a>(scope: CapabilityScope<Run>) -> CapabilityLease<'a, Run> {
scope.lease().unwrap()
}Marker types also prevent a narrower Turn lease from entering a Run-only API:
ⓘ
use a3s_code_core::capability::{CapabilityLease, Run, Turn};
fn needs_run(_lease: CapabilityLease<'_, Run>) {}
fn wrong_scope(lease: CapabilityLease<'_, Turn>) {
needs_run(lease);
}Implementations§
Source§impl<'scope, K: ScopeKind> CapabilityLease<'scope, K>
impl<'scope, K: ScopeKind> CapabilityLease<'scope, K>
pub fn scope_id(&self) -> &CapabilityScopeId
pub const fn kind(&self) -> CapabilityScopeKind
pub fn parent_id(&self) -> Option<&CapabilityScopeId>
pub fn catalog_generation(&self) -> CodeCatalogGeneration
pub fn catalog_digest(&self) -> &Sha256Digest
pub fn use_generation(&self) -> Option<&UseCapabilityGeneration>
pub fn ceiling(&self) -> &CapabilityCeiling
pub fn cancellation(&self) -> CancellationToken
pub fn get( &self, id: &CapabilityId, ) -> Result<Option<&'scope CapabilityDescriptor>, CapabilityScopeError>
pub fn contains(&self, id: &CapabilityId) -> Result<bool, CapabilityScopeError>
pub fn iter( &self, ) -> Result<impl Iterator<Item = (&'scope CapabilityId, &'scope CapabilityDescriptor)> + 'scope, CapabilityScopeError>
Trait Implementations§
Auto Trait Implementations§
impl<'scope, K> Freeze for CapabilityLease<'scope, K>where
PhantomData<K>: Freeze,
impl<'scope, K> RefUnwindSafe for CapabilityLease<'scope, K>where
PhantomData<K>: RefUnwindSafe,
impl<'scope, K> Send for CapabilityLease<'scope, K>where
PhantomData<K>: Send,
impl<'scope, K> Sync for CapabilityLease<'scope, K>where
PhantomData<K>: Sync,
impl<'scope, K> Unpin for CapabilityLease<'scope, K>where
PhantomData<K>: Unpin,
impl<'scope, K> UnsafeUnpin for CapabilityLease<'scope, K>where
PhantomData<K>: UnsafeUnpin,
impl<'scope, K> UnwindSafe for CapabilityLease<'scope, K>where
PhantomData<K>: UnwindSafe,
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
Source§fn with_current_context(self) -> WithContext<Self> ⓘ
fn with_current_context(self) -> WithContext<Self> ⓘ
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> ⓘ
Converts
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> ⓘ
Converts
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