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>
impl<'a> Name<'a>
Sourcepub fn new<S>(string: S, mangling: NameMangling, lang: Language) -> Self
pub fn new<S>(string: S, mangling: NameMangling, lang: Language) -> Self
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++]");
Sourcepub fn as_str(&self) -> &str
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");
Sourcepub fn set_language(&mut self, language: Language) -> &mut Self
pub fn set_language(&mut self, language: Language) -> &mut Self
Set the Name
’s language.
Sourcepub fn language(&self) -> Language
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);
Sourcepub fn set_mangling(&mut self, mangling: NameMangling) -> &mut Self
pub fn set_mangling(&mut self, mangling: NameMangling) -> &mut Self
Set the Name
’s mangling state.
Sourcepub fn mangling(&self) -> NameMangling
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);
Sourcepub fn into_string(self) -> String
pub fn into_string(self) -> String
Trait Implementations§
Source§impl<'de, 'a> Deserialize<'de> for Name<'a>
impl<'de, 'a> Deserialize<'de> for Name<'a>
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
impl<'a> Eq for Name<'a>
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> 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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)