Skip to main content

Crate facet_python

Crate facet_python 

Source
Expand description

Generate Python type definitions from facet type metadata.

This crate uses facet’s reflection capabilities to generate Python type hints and TypedDicts from any type that implements Facet.

§Example

use facet::Facet;
use facet_python::to_python;

#[derive(Facet)]
struct User {
    name: String,
    age: u32,
    email: Option<String>,
}

let py = to_python::<User>(false);
assert!(py.contains("class User(TypedDict"));

Structs§

PythonGenerator
Generator for Python type definitions.

Functions§

to_python
Generate Python definitions for a single type.