Loading...
Loading...
#[ossido::Environment] - mark the project's typed environment schema. See environment::environment_attr for the full contract (typed FromStr parsing, required vs Option fields, the #[public] helper, and the generated from_env / public-JSON methods). Read fields in Rust via ossido::get_env!; TypeScript types for the public fields are generated only when this struct exists.
The struct becomes the single source of truth for configuration: fields are parsed and validated once at startup, and only the fields you mark `#[public]` are exposed to the frontend (with generated TypeScript types). The whole feature is optional - define no `Environment` struct and nothing is generated. Name fields in `SCREAMING_SNAKE` so the key is identical everywhere - the OS variable, `get_env!`, and `getEnv`. A non-`Option` field is required (a missing or unparseable value panics at startup); an `Option<T>` field is optional. Read fields in Rust with `get_env!`, and public fields on the frontend with `getEnv`.
Define the schema (convention: `src/env.rs`):