pub struct AppConfig {
pub backend: Backend,
pub python_exe: String,
pub include: Vec<PathBuf>,
pub inputs: Vec<String>,
pub out: PathBuf,
pub generate_mypy: bool,
pub generate_mypy_grpc: bool,
pub postprocess: PostProcess,
pub verify: Option<Verify>,
}Expand description
Main application configuration parsed from pyproject.toml.
Contains all settings needed to run the proto-to-Python code generation pipeline, including backend selection, file paths, and processing options.
Fields§
§backend: BackendBackend to use for code generation (protoc or buf).
python_exe: StringPython executable to use for generation and verification. Can be “python3”, “python”, “uv”, or a custom path.
include: Vec<PathBuf>Proto import paths (passed as –proto_path to protoc). These directories are searched for proto files and their dependencies.
inputs: Vec<String>Glob patterns for proto files to compile. Only files matching these patterns will be processed.
out: PathBufOutput directory for generated Python files.
generate_mypy: boolWhether to generate mypy type stubs (.pyi files) using mypy-protobuf.
generate_mypy_grpc: boolWhether to generate gRPC mypy stubs (_grpc.pyi files) using mypy-grpc.
postprocess: PostProcessPost-processing configuration options.
verify: Option<Verify>Optional verification configuration (type checking commands).
Implementations§
Source§impl AppConfig
impl AppConfig
Sourcepub fn load(pyproject_path: Option<&Path>) -> Result<Self>
pub fn load(pyproject_path: Option<&Path>) -> Result<Self>
Load configuration from a pyproject.toml file.
Parses the TOML configuration file and validates the settings, applying defaults where values are not specified.
§Arguments
pyproject_path- Optional path to the pyproject.toml file. If None, looks for “pyproject.toml” in the current directory.
§Returns
Returns the parsed and validated configuration, or an error if:
- The file cannot be read
- The TOML is malformed
- Required configuration sections are missing
- Configuration values are invalid
§Example
use python_proto_importer::config::AppConfig;
use std::path::Path;
// Load from default location
let config = AppConfig::load(None)?;
// Load from custom path
let config = AppConfig::load(Some(Path::new("custom.toml")))?;