fieldenum
Rust-like fielded Enums in Python
Examples
from fieldenum import fieldenum, Unit, Variant
@fieldenum
class Message:
Quit = Unit
Move = Variant(x=int, y=int)
Write = Variant(str)
ChangeColor = Variant(int, int, int)
# Corresponding code in Rust:
# enum Message {
# Quit,
# Move { x: i32, y: i32 },
# Write(String),
# ChangeColor(i32, i32, i32),
# }
# usage
message = Message.Quit
message = Message.Move(x=1, y=2)
message = Message.Write("hello, world!")
message = Message.ChangeColor(256, 256, 0)
Credits
This project is heavily influenced by Rust's Enum, and also borrows some of its design from rust_enum.
Releases
- 0.1.0: initial release
Metadata
Release files for fieldenum 0.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| fieldenum-0.2.0.tar.gz | 9.2 kB | Without provenance | Details for fieldenum-0.2.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| fieldenum-0.2.0-py3-none-any.whl | Python 3 | none | any | Details for fieldenum-0.2.0-py3-none-any.whl |
Total release size: 19.0 kB
Release files / fieldenum-0.2.0.tar.gz
| Download URL | fieldenum-0.2.0.tar.gz |
|---|---|
| Size | 9.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
7997d97154b86fd2fed3df9951539cb2b9ae4b26f38f71185fdea98423a3ada2
|
|
BLAKE2b-256 checksum How to use checksums |
0a8e546e898513bda0b3f7b6e90288e0e0e4c0f067ca5e1dd77319c047598b84
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.8.3 CPython/3.12.5 Windows/11
|
Release files / fieldenum-0.2.0-py3-none-any.whl
| Download URL | fieldenum-0.2.0-py3-none-any.whl |
|---|---|
| Size | 9.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
ec5a6b12f463fb8769530794016054b9b7990206f9e2ecec1c6e11ab94353a8b
|
|
BLAKE2b-256 checksum How to use checksums |
71b6008ce14dd5429a1133ac253ce1de7aabdc6f4fcfab4e589802c45a66bb86
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.8.3 CPython/3.12.5 Windows/11
|
Security for fieldenum 0.2.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.