#[non_exhaustive]pub struct ConfigFile {
pub target: Option<Target>,
pub layout: Option<Layout>,
pub validation: Option<bool>,
pub exact_numbers: Option<bool>,
pub header: Option<String>,
pub extra_imports: Vec<String>,
pub allow_codegen_extensions: Option<bool>,
pub template_dir: Option<PathBuf>,
pub rust: RustConfigFile,
pub go: GoConfigFile,
pub substitutions: BTreeMap<String, Substitution>,
pub types: BTreeMap<String, TypeConfig>,
}Expand description
What a configuration file may say. Everything optional; nothing validated beyond the shape.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.target: Option<Target>§layout: Option<Layout>§validation: Option<bool>§exact_numbers: Option<bool>§header: Option<String>§extra_imports: Vec<String>§allow_codegen_extensions: Option<bool>§template_dir: Option<PathBuf>A directory of templates overriding the built-in ones. Relative paths resolve against the configuration file’s directory.
rust: RustConfigFile§go: GoConfigFile§substitutions: BTreeMap<String, Substitution>Keyed by format name or by component name.
types: BTreeMap<String, TypeConfig>Implementations§
Source§impl ConfigFile
impl ConfigFile
Sourcepub fn from_path(path: &Path) -> Result<ConfigFile, ConfigError>
pub fn from_path(path: &Path) -> Result<ConfigFile, ConfigError>
Read and parse a file. Relative paths inside it resolve against the file’s own directory, never the working directory, so a checked-in configuration means the same thing from every shell.
Sourcepub fn from_toml(text: &str, base: &Path) -> Result<ConfigFile, ConfigError>
pub fn from_toml(text: &str, base: &Path) -> Result<ConfigFile, ConfigError>
Parse TOML text. base is what relative paths resolve against;
it is taken explicitly because text has no location of its own.
Sourcepub fn merge(self, over: ConfigFile) -> ConfigFile
pub fn merge(self, over: ConfigFile) -> ConfigFile
Layer over on top of self: a value over sets wins, a value
it leaves unset keeps self’s. Lists and maps combine, later
entries winning on the same key. This is how a command line
applies to a file: parse the file, build a ConfigFile from the
flags, merge.
Sourcepub fn build(self) -> Result<Config, ConfigError>
pub fn build(self) -> Result<Config, ConfigError>
Resolve into what generation consumes. This is where “required”
is enforced: a missing target is an error here and nowhere else.
Trait Implementations§
Source§impl Clone for ConfigFile
impl Clone for ConfigFile
Source§impl Debug for ConfigFile
impl Debug for ConfigFile
Source§impl Default for ConfigFile
impl Default for ConfigFile
Source§impl<'de> Deserialize<'de> for ConfigFilewhere
ConfigFile: Default,
impl<'de> Deserialize<'de> for ConfigFilewhere
ConfigFile: Default,
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
impl Eq for ConfigFile
Source§impl PartialEq for ConfigFile
impl PartialEq for ConfigFile
impl StructuralPartialEq for ConfigFile
Auto Trait Implementations§
impl Forget for ConfigFile
impl Freeze for ConfigFile
impl Move for ConfigFile
impl RefUnwindSafe for ConfigFile
impl Send for ConfigFile
impl Sync for ConfigFile
impl Unpin for ConfigFile
impl UnsafeUnpin for ConfigFile
impl UnwindSafe for ConfigFile
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.