Skip to main content

SpanText

Trait SpanText 

Source
pub trait SpanText:
    Debug
    + Eq
    + Hash
    + Borrow<str>
    + Serialize
    + Default {
    // Required methods
    fn from_static_str(value: &'static str) -> Self;
    fn from_owned(value: String) -> Self;

    // Provided method
    fn to_bytes_string(&self) -> BytesString { ... }
}
Expand description

Trait representing the requirements for a type to be used as a Span “string” type. Note: Borrow is not required by the derived traits, but allows to access HashMap elements from a static str and check if the string is empty.

Required Methods§

Source

fn from_static_str(value: &'static str) -> Self

Source

fn from_owned(value: String) -> Self

Provided Methods§

Source

fn to_bytes_string(&self) -> BytesString

Copies this text into an owned BytesString.

Used by the v0.5 conversion, whose shared dictionary always owns its strings so it can hold both interned span text and dynamically-built JSON (span links / events). The default copies the bytes; owned text types (e.g. BytesString) should override with a cheaper reference-counted clone.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl SpanText for BytesString

Source§

fn from_static_str(value: &'static str) -> Self

Source§

fn to_bytes_string(&self) -> BytesString

Source§

fn from_owned(value: String) -> Self

Source§

impl SpanText for Cow<'_, str>

Source§

fn from_static_str(value: &'static str) -> Self

Source§

fn from_owned(value: String) -> Self

Implementors§