pub trait Demangle {
    fn detect_language(&self) -> Language;
    fn demangle(&self, opts: DemangleOptions) -> Option<String>;
    fn try_demangle(&self, opts: DemangleOptions) -> Cow<'_, str>;
}
Expand description

An extension trait on Name for demangling names.

See the module level documentation for a list of supported languages.

Required Methods§

Infers the language of a mangled name.

In case the symbol is not mangled or its language is unknown, the return value will be Language::Unknown. If the language of the symbol was specified explicitly, this is returned instead. For a list of supported languages, see the module level documentation.

Examples
use symbolic_common::{Language, Name};
use symbolic_demangle::{Demangle, DemangleOptions};

assert_eq!(Name::from("_ZN3foo3barEv").detect_language(), Language::Cpp);
assert_eq!(Name::from("unknown").detect_language(), Language::Unknown);

Demangles the name with the given options.

Returns None in one of the following cases:

  1. The language cannot be detected.
  2. The language is not supported.
  3. Demangling of the name failed.
Examples
use symbolic_common::Name;
use symbolic_demangle::{Demangle, DemangleOptions};

assert_eq!(
    Name::from("_ZN3foo3barEv").demangle(DemangleOptions::name_only()),
    Some("foo::bar".to_string())
);
assert_eq!(
    Name::from("unknown").demangle(DemangleOptions::name_only()),
    None
);

Tries to demangle the name and falls back to the original name.

Similar to demangle, except that it returns a borrowed instance of the original name if the name cannot be demangled.

Examples
use symbolic_common::Name;
use symbolic_demangle::{Demangle, DemangleOptions};

assert_eq!(
    Name::from("_ZN3foo3barEv").try_demangle(DemangleOptions::name_only()),
    "foo::bar"
);
assert_eq!(
    Name::from("unknown").try_demangle(DemangleOptions::name_only()),
    "unknown"
);

Implementations on Foreign Types§

Implementors§