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

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++]");

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");

Set the Name’s 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);

Set the Name’s mangling state.

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);

Converts this name into a Cow.

Example
use symbolic_common::Name;

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

Converts this name into a String.

Example
use symbolic_common::Name;

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

Trait Implementations

Converts this type into a shared reference of the (usually inferred) input type.
Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more
Infers the language of a mangled name. Read more
Demangles the name with the given options. Read more
Tries to demangle the name and falls back to the original name. Read more
Deserialize this value from the given Serde deserializer. Read more
Formats the value using the given formatter. Read more
Converts to this type from the input type.
Feeds this value into the given Hasher. Read more
Feeds a slice of this type into the given Hasher. Read more
This method tests for self and other values to be equal, and is used by ==. Read more
This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason. Read more
This method tests for self and other values to be equal, and is used by ==. Read more
This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason. Read more
This method tests for self and other values to be equal, and is used by ==. Read more
This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason. Read more
This method tests for self and other values to be equal, and is used by ==. Read more
This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason. Read more
This method tests for self and other values to be equal, and is used by ==. Read more
This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason. Read more
This method tests for self and other values to be equal, and is used by ==. Read more
This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason. Read more
This method tests for self and other values to be equal, and is used by ==. Read more
This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason. Read more
Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more
Converts self into T using Into<T>. Read more
Compare self to key and return true if they are equal.
Unerase this erased pointer. Read more
Whether this implementor has acknowledged the 1.1.0 update to unerase’s documented implementation requirements. Read more
Turn this erasable pointer into an erased pointer. Read more
Given the context attached to a nom error, and given the original input to the nom parser, extract more the useful context information. Read more
Causes self to use its Binary implementation when Debug-formatted. Read more
Causes self to use its Display implementation when Debug-formatted. Read more
Causes self to use its LowerExp implementation when Debug-formatted. Read more
Causes self to use its LowerHex implementation when Debug-formatted. Read more
Causes self to use its Octal implementation when Debug-formatted. Read more
Causes self to use its Pointer implementation when Debug-formatted. Read more
Causes self to use its UpperExp implementation when Debug-formatted. Read more
Causes self to use its UpperHex implementation when Debug-formatted. Read more
Formats each item in a sequence. Read more

Returns the argument unchanged.

Wrap this object so that its Display representation is indented with the given indent. Each non-empty line of the formatted output will be prefixed with the indent. Read more
Wrap this object so that its Display representation is indented with the given indent. Each non-empty line except for the first of the formatted output will be prefixed with the indent. Read more
Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Instruments this type with the current Span, returning an Instrumented wrapper. Read more

Calls U::from(self).

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

Pipes by value. This is generally the method you want to use. Read more
Borrows self and passes that borrow into the pipe function. Read more
Mutably borrows self and passes that borrow into the pipe function. Read more
Borrows self, then passes self.borrow() into the pipe function. Read more
Mutably borrows self, then passes self.borrow_mut() into the pipe function. Read more
Borrows self, then passes self.as_ref() into the pipe function.
Mutably borrows self, then passes self.as_mut() into the pipe function. Read more
Borrows self, then passes self.deref() into the pipe function.
Mutably borrows self, then passes self.deref_mut() into the pipe function. Read more
Given the original input, as well as the context reported by nom, recreate a context in the original string where the error occurred. Read more
Immutable access to a value. Read more
Mutable access to a value. Read more
Immutable access to the Borrow<B> of a value. Read more
Mutable access to the BorrowMut<B> of a value. Read more
Immutable access to the AsRef<R> view of a value. Read more
Mutable access to the AsMut<R> view of a value. Read more
Immutable access to the Deref::Target of a value. Read more
Mutable access to the Deref::Target of a value. Read more
Calls .tap() only in debug builds, and is erased in release builds.
Calls .tap_mut() only in debug builds, and is erased in release builds. Read more
Calls .tap_borrow() only in debug builds, and is erased in release builds. Read more
Calls .tap_borrow_mut() only in debug builds, and is erased in release builds. Read more
Calls .tap_ref() only in debug builds, and is erased in release builds. Read more
Calls .tap_ref_mut() only in debug builds, and is erased in release builds. Read more
Calls .tap_deref() only in debug builds, and is erased in release builds. Read more
Calls .tap_deref_mut() only in debug builds, and is erased in release builds. Read more
The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
Converts the given value to a String. Read more
Attempts to convert self into T using TryInto<T>. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.
Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more