pub struct Label<'computed> { /* private fields */ }
Expand description
A textual label for some value.
Implementations§
source§impl<'computed> Label<'computed>
impl<'computed> Label<'computed>
sourcepub const fn new(label: &'static str) -> Self
pub const fn new(label: &'static str) -> Self
Create a new label from a static string value.
For labels that can’t satisfy the 'static
lifetime, use Label::new_computed
.
For labels that need owned values, use Label::new_owned
.
sourcepub const fn new_computed(label: &'computed str) -> Self
pub const fn new_computed(label: &'computed str) -> Self
Create a new label from a string value borrowed for the 'computed
lifetime.
sourcepub const fn as_static_str(&self) -> Option<&'static str>
pub const fn as_static_str(&self) -> Option<&'static str>
Try get the value of the label as a static string.
For labels that were created over computed data this method will return None
.
sourcepub const fn with_tag(self, tag: &Tag) -> Self
pub const fn with_tag(self, tag: &Tag) -> Self
Associate a tag as a hint with this label.
Tags don’t contribute to equality or ordering of labels but streams may use the them when interpreting the label value.
sourcepub const fn tag(&self) -> Option<&Tag>
pub const fn tag(&self) -> Option<&Tag>
Get the tag hint associated with the label, if present.
Streams may use the tag when interpreting the label value.
sourcepub fn try_to_owned(&self) -> Result<Label<'static>>
pub fn try_to_owned(&self) -> Result<Label<'static>>
Try create an owned label from this one.
This method will always return Ok
if the alloc
feature is enabled.
If the alloc
feature is not enabled then this method will only return Ok
if the underlying value is already 'static
.