Struct ResourceToken
pub struct ResourceToken<'a> { /* private fields */ }
Expand description
An opaque token associated with a resource.
It can be used to create debug and trace identifiers for the resource, but it should not be used as a unique identifier of the resource inside the netstack.
By default the lifetime of a token is bound the resource that token
belongs to, but it can be extended by calling
ResourceToken::extend_lifetime
.
Implementations§
§impl<'a> ResourceToken<'a>
impl<'a> ResourceToken<'a>
pub fn extend_lifetime(self) -> ResourceToken<'static>
pub fn extend_lifetime(self) -> ResourceToken<'static>
Extends lifetime of the token.
§Discussion
It’s generally okay to extend the lifetime of the token, but prefer to use tokens bound to the resource’s lifetime whenever possible, since it provides guardrails against identifiers that outlive the resource itself.
pub fn export_value(self) -> u64
pub fn export_value(self) -> u64
Returns internal value. Consumes self
.
§Discussion
Export to u64
when a representation is needed for interaction with
other processes or components such as trace identifiers and eBPF
socket cookies.
Refrain from using the returned value within the netstack otherwise.
Trait Implementations§
Auto Trait Implementations§
impl<'a> Freeze for ResourceToken<'a>
impl<'a> RefUnwindSafe for ResourceToken<'a>
impl<'a> Send for ResourceToken<'a>
impl<'a> Sync for ResourceToken<'a>
impl<'a> Unpin for ResourceToken<'a>
impl<'a> UnwindSafe for ResourceToken<'a>
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<T, D> Encode<Ambiguous1, D> for Twhere
D: ResourceDialect,
impl<T, D> Encode<Ambiguous1, D> for Twhere
D: ResourceDialect,
§impl<T, D> Encode<Ambiguous2, D> for Twhere
D: ResourceDialect,
impl<T, D> Encode<Ambiguous2, D> for Twhere
D: ResourceDialect,
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