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§
Source§impl<'a> ResourceToken<'a>
impl<'a> ResourceToken<'a>
Sourcepub 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.
Sourcepub 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.