symbolic_common

Struct Name

Source
pub struct Name<'a> { /* private fields */ }
Expand description

The name of a potentially mangled symbol.

Debugging information often only contains mangled names in their symbol and debug information data. The mangling schema depends on the compiler and programming language. Name is a wrapper type for potentially mangled names and an optionally declared language. To demangle the name, see the demangle feature of symbolic.

Not all sources declare a programming language. In such a case, the language will be Unknown. However, it may still be inferred for demangling by inspecting the mangled string.

Names can refer either functions, types, fields, or virtual constructs. Their semantics are fully defined by the language and the compiler.

§Examples

Create a name and print it:

use symbolic_common::Name;

let name = Name::from("_ZN3foo3barEv");
assert_eq!(name.to_string(), "_ZN3foo3barEv");

Create a name with a language and explicit mangling state. Alternate formatting prints the language:

use symbolic_common::{Language, Name, NameMangling};

let name = Name::new("_ZN3foo3barEv", NameMangling::Mangled, Language::Cpp);
assert_eq!(format!("{:#}", name), "_ZN3foo3barEv [C++]");

Implementations§

Source§

impl<'a> Name<'a>

Source

pub fn new<S>(string: S, mangling: NameMangling, lang: Language) -> Self
where S: Into<Cow<'a, str>>,

Constructs a new Name with given mangling and language.

In case both the mangling state and the language are unknown, a simpler alternative to use is Name::from.

§Example
use symbolic_common::{Language, Name, NameMangling};

let name = Name::new("_ZN3foo3barEv", NameMangling::Mangled, Language::Cpp);
assert_eq!(format!("{:#}", name), "_ZN3foo3barEv [C++]");
Source

pub fn as_str(&self) -> &str

Returns the raw, mangled string of the name.

§Example
use symbolic_common::{Language, Name, NameMangling};

let name = Name::new("_ZN3foo3barEv", NameMangling::Mangled, Language::Cpp);
assert_eq!(name.as_str(), "_ZN3foo3barEv");

This is also available as an AsRef<str> implementation:

use symbolic_common::{Language, Name, NameMangling};

let name = Name::new("_ZN3foo3barEv", NameMangling::Mangled, Language::Cpp);
assert_eq!(name.as_ref(), "_ZN3foo3barEv");
Source

pub fn set_language(&mut self, language: Language) -> &mut Self

Set the Name’s language.

Source

pub fn language(&self) -> Language

The language of the mangled symbol.

If the language is not declared in the source, this returns Language::Unknown. The language may still be inferred using detect_language, which is declared on the Demangle extension trait.

§Example
use symbolic_common::{Language, Name, NameMangling};

let name = Name::new("_ZN3foo3barEv", NameMangling::Mangled, Language::Cpp);
assert_eq!(name.language(), Language::Cpp);
Source

pub fn set_mangling(&mut self, mangling: NameMangling) -> &mut Self

Set the Name’s mangling state.

Source

pub fn mangling(&self) -> NameMangling

Returns the Name’s mangling state.

§Example
use symbolic_common::{Language, Name, NameMangling};

let unmangled = Name::new("foo::bar", NameMangling::Unmangled, Language::Unknown);
assert_eq!(unmangled.mangling(), NameMangling::Unmangled);
Source

pub fn into_cow(self) -> Cow<'a, str>

Converts this name into a Cow.

§Example
use symbolic_common::Name;

let name = Name::from("_ZN3foo3barEv");
assert_eq!(name.into_cow(), "_ZN3foo3barEv");
Source

pub fn into_string(self) -> String

Converts this name into a String.

§Example
use symbolic_common::Name;

let name = Name::from("_ZN3foo3barEv");
assert_eq!(name.into_string(), "_ZN3foo3barEv");

Trait Implementations§

Source§

impl AsRef<str> for Name<'_>

Source§

fn as_ref(&self) -> &str

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl<'a> Clone for Name<'a>

Source§

fn clone(&self) -> Name<'a>

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<'a> Debug for Name<'a>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de, 'a> Deserialize<'de> for Name<'a>

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Display for Name<'_>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl From<Name<'_>> for String

Source§

fn from(name: Name<'_>) -> Self

Converts to this type from the input type.
Source§

impl<'a, S> From<S> for Name<'a>
where S: Into<Cow<'a, str>>,

Source§

fn from(string: S) -> Self

Converts to this type from the input type.
Source§

impl<'a> Hash for Name<'a>

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl<'a, 'b> PartialEq<&'b str> for Name<'a>

Source§

fn eq(&self, other: &&'b str) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<'a, 'b> PartialEq<Cow<'b, str>> for Name<'a>

Source§

fn eq(&self, other: &Cow<'b, str>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<'a, 'b> PartialEq<Name<'a>> for &'b str

Source§

fn eq(&self, other: &Name<'a>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<'a, 'b> PartialEq<Name<'a>> for Cow<'b, str>

Source§

fn eq(&self, other: &Name<'a>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<'a, 'b> PartialEq<Name<'a>> for String

Source§

fn eq(&self, other: &Name<'a>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<'a, 'b> PartialEq<Name<'a>> for str

Source§

fn eq(&self, other: &Name<'a>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<'a, 'b> PartialEq<String> for Name<'a>

Source§

fn eq(&self, other: &String) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<'a, 'b> PartialEq<str> for Name<'a>

Source§

fn eq(&self, other: &str) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<'a> PartialEq for Name<'a>

Source§

fn eq(&self, other: &Name<'a>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<'a> Serialize for Name<'a>

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl<'a> Eq for Name<'a>

Source§

impl<'a> StructuralPartialEq for Name<'a>

Auto Trait Implementations§

§

impl<'a> Freeze for Name<'a>

§

impl<'a> RefUnwindSafe for Name<'a>

§

impl<'a> Send for Name<'a>

§

impl<'a> Sync for Name<'a>

§

impl<'a> Unpin for Name<'a>

§

impl<'a> UnwindSafe for Name<'a>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dst: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,