pub struct StackLabel { /* private fields */ }Expand description
Human-readable application, framework, runtime, or service label.
A label pairs display text with a StackKind. Built-in labels borrow
static strings, so producing them never allocates. Use
as_str, AsRef<str>, or Display to
read the text, and kind for the category.
Equality and hashing consider both text and kind. Comparisons with str
and &str consider only the text, which keeps assertions short.
§Examples
use what_stack::{StackKind, StackLabel, detect_from_process};
let label: StackLabel = detect_from_process("postgres").expect("known process");
assert_eq!(label, "PostgreSQL");
assert_eq!(label.as_str(), "PostgreSQL");
assert_eq!(label.kind(), StackKind::Database);
assert_eq!(label.to_string(), "PostgreSQL");Implementations§
Source§impl StackLabel
impl StackLabel
Sourcepub fn new(text: impl Into<Cow<'static, str>>, kind: StackKind) -> Self
pub fn new(text: impl Into<Cow<'static, str>>, kind: StackKind) -> Self
Create a label from owned or static text.
Prefer from_static for string literals; it is a
const fn and never allocates.
Sourcepub const fn from_static(text: &'static str, kind: StackKind) -> Self
pub const fn from_static(text: &'static str, kind: StackKind) -> Self
Create a label from static text without allocating.
Trait Implementations§
Source§impl AsRef<str> for StackLabel
impl AsRef<str> for StackLabel
Source§impl Clone for StackLabel
impl Clone for StackLabel
Source§impl Debug for StackLabel
impl Debug for StackLabel
Source§impl Display for StackLabel
impl Display for StackLabel
impl Eq for StackLabel
Source§impl From<StackLabel> for Cow<'static, str>
impl From<StackLabel> for Cow<'static, str>
Source§fn from(label: StackLabel) -> Self
fn from(label: StackLabel) -> Self
Converts to this type from the input type.
Source§impl From<StackLabel> for String
impl From<StackLabel> for String
Source§fn from(label: StackLabel) -> Self
fn from(label: StackLabel) -> Self
Converts to this type from the input type.
Source§impl Hash for StackLabel
impl Hash for StackLabel
Source§impl PartialEq for StackLabel
impl PartialEq for StackLabel
Source§impl PartialEq<&str> for StackLabel
impl PartialEq<&str> for StackLabel
Source§impl PartialEq<StackLabel> for str
impl PartialEq<StackLabel> for str
Source§impl PartialEq<StackLabel> for &str
impl PartialEq<StackLabel> for &str
Source§impl PartialEq<str> for StackLabel
impl PartialEq<str> for StackLabel
impl StructuralPartialEq for StackLabel
Auto Trait Implementations§
impl Freeze for StackLabel
impl RefUnwindSafe for StackLabel
impl Send for StackLabel
impl Sync for StackLabel
impl Unpin for StackLabel
impl UnsafeUnpin for StackLabel
impl UnwindSafe for StackLabel
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