pyenum 0.0.1

Expose Rust enums to Python as real enum.Enum subclasses via PyO3.
Documentation
//! # pyenum
//!
//! Expose Rust `enum` types to Python as genuine `enum.Enum` subclasses via
//! PyO3 — `#[derive(PyEnum)]`, functional-API class construction, a
//! per-interpreter cache, and `IntoPyObject` / `FromPyObject` conversion
//! plumbing generated by the derive.
//!
//! ## Scope
//!
//! * Unit-variant enums only; tuple / struct / generic / lifetime-parameterised
//!   enums are rejected at compile time.
//! * Five Python enum bases are selectable: `Enum` (default), `IntEnum`,
//!   `StrEnum`, `Flag`, `IntFlag`.
//! * Rust variant names are passed through unchanged (Python member name ==
//!   Rust identifier).
//! * The Python class is constructed exactly once per interpreter and cached
//!   via `pyo3::sync::PyOnceLock`.
//! * PyO3 0.28, CPython 3.11+.
//! * Free-threaded (`--disable-gil`) Python, module reload, and sub-interpreter
//!   finalisation are out of scope.

#![deny(missing_debug_implementations)]
#![cfg_attr(docsrs, feature(doc_cfg))]

mod cache;
mod construct;
mod register;
mod trait_def;

pub use pyenum_derive::PyEnum;
pub use register::{PyModuleExt, add_enum};
pub use trait_def::{PyEnum as PyEnumTrait, PyEnumBase, PyEnumSpec, VariantLiteral};

/// Implementation detail — referenced by the output of `#[derive(PyEnum)]`.
///
/// Consumers MUST NOT import anything from this module directly; its shape is
/// allowed to change between patch releases without warning.
#[doc(hidden)]
pub mod __private {
    pub use ::pyo3;
    pub use ::pyo3::sync::PyOnceLock as OnceLock;

    pub use crate::cache::get_or_build;
    pub use crate::construct::build_py_enum;
    pub use crate::trait_def::{PyEnum, PyEnumBase, PyEnumSpec, VariantLiteral};
}