Skip to content

tedanvosin/pyderust

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

pyderust

Python bindings for the rustc-demangle crate.

Installation

pip install pyderust

Usage

from pyderust import demangle, DemangleError

# Demangle a Rust symbol (legacy mangling)
demangle("_ZN3foo3barE")  # => "foo::bar"

# Demangle a v0 symbol
demangle("_RNvC4test4main")  # => "test::main"

# Include the hash suffix
demangle("_ZN3foo17h05af221e174051e8E", include_hash=True)  # => "foo::h05af221e174051e8"

# Without hash (default)
demangle("_ZN3foo17h05af221e174051e8E")  # => "foo"

Error Handling

DemangleError is raised when a symbol cannot be demangled. It is a subclass of ValueError.

from pyderust import demangle, DemangleError

try:
    demangle("not_a_rust_symbol")
except DemangleError as e:
    print(e)  # => "not a valid Rust mangled symbol: not_a_rust_symbol"

Development

# Create a virtual environment and install dev dependencies
python -m venv .venv
source .venv/bin/activate
pip install maturin pytest

# Build and install in development mode
maturin develop

# Run tests
pytest

About

Python bindings for rustc-demangle

Resources

License

Stars

0 stars

Watchers

0 watching

Forks

Packages

 
 
 

Contributors