pub struct Subleases { /* private fields */ }Expand description
Subleases on a leased resource.
In some scenarios, a leased resource may actually represent a collection of “subresources” that can be handed out piecemeal, at arbitrary points in time. These subresources are often wrapped in their own types to ensure proper behavior (RAII style), but ultimately must roll back up to the original leased resource to ensure proper behavior within the resource registry. This requires knowing, deterministically, when a leased resource has returned completely.
Subleases provide an RAII guard mechanism that allows an owned guard to be paired with a subresource such that when the subresource is dropped, the sublease is dropped with it. Subleases are tracked by a parent leased resource, and only when all subleases have been dropped is the parent leased resource able to be reacquired by another caller.
Subleases is not itself a sublease. It deliberately doesn’t keep the resource’s lease alive: a handle kept in
order to issue subleases would otherwise hold the resource’s lease open for as long as the resource existed, and
no acquirer would ever be handed it again.
Implementations§
Source§impl Subleases
impl Subleases
Sourcepub fn issue(&self) -> Option<Sublease>
pub fn issue(&self) -> Option<Sublease>
Issues a sublease, held until the returned value is dropped.
Returns None once the resource’s registry entry is gone, leaving nothing to record a sublease against. That
only happens after the resource itself has been dropped – a
discarded resource keeps its entry until its subleases are returned – so a
resource still in use always gets its sublease.
§Subleasing after the head lease is returned
Nothing here prevents a sublease being issued after the head lease has gone back to the registry, which under the property-law reading of the name shouldn’t be possible. In practice a resource is only reachable through its head lease, so a holder has nothing to issue against once it has released it. Genuinely preventing it would mean fixing the number of subleases up front, or issuing them all eagerly and handing them out, which costs more than the case is worth.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Subleases
impl RefUnwindSafe for Subleases
impl Send for Subleases
impl Sync for Subleases
impl Unpin for Subleases
impl UnwindSafe for Subleases
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::RequestSource§impl<T> Pointable for T
impl<T> Pointable for T
§impl<T> Track for T
impl<T> Track for T
§fn track_resources(self, token: ResourceGroupToken) -> Tracked<Self>
fn track_resources(self, token: ResourceGroupToken) -> Tracked<Self>
Tracked wrapper. Read more§fn in_current_resource_group(self) -> Tracked<Self>
fn in_current_resource_group(self) -> Tracked<Self>
Tracked wrapper. Read more