pub struct Config { /* private fields */ }Expand description
Config
§Examples
let input = String::from("
#define bar 42
foo = bar;
");
let config = Config::from_string(input, None, &Vec::new(), &mut Warnings::new()).expect("Failed to parse config");
assert_eq!("foo = 42;\n", config.to_string().unwrap());
assert_eq!(b"\0raP", &config.to_cursor().unwrap().into_inner()[..4]);Implementations§
Source§impl Config
impl Config
Sourcepub fn root(&self) -> &ConfigClass
pub fn root(&self) -> &ConfigClass
The unnamed top-level class holding all entries of the file.
Sourcepub fn enum_values(&self) -> &[(String, i32)]
pub fn enum_values(&self) -> &[(String, i32)]
The values of the enum { ... } blocks, in source order (or table order for a rapified config).
Names are lowercase, as the game stores them. The values of all blocks, at any class level, land in this one table.
Sourcepub fn write_with<O: Write>(
&self,
output: &mut O,
options: &WriteOptions,
) -> Result<(), Error>
pub fn write_with<O: Write>( &self, output: &mut O, options: &WriteOptions, ) -> Result<(), Error>
Writes the config (unrapified) to the output with the given options.
§Errors
Returns an error on I/O failure or if a name cannot be written as text.
Sourcepub fn to_string(&self) -> Result<String, Error>
pub fn to_string(&self) -> Result<String, Error>
Returns the unrapified config as a string.
§Errors
Returns an error on I/O failure or invalid UTF-8 in the output.
Sourcepub fn write_rapified<O: Write>(&self, output: &mut O) -> Result<(), Error>
pub fn write_rapified<O: Write>(&self, output: &mut O) -> Result<(), Error>
Writes the rapified config to the output.
§Errors
Returns an error on I/O failure or if the config cannot be rapified.
Sourcepub fn read<I: Read>(
input: &mut I,
path: Option<PathBuf>,
includefolders: &[PathBuf],
warnings: &mut dyn WarningSink,
) -> Result<Config, Error>
pub fn read<I: Read>( input: &mut I, path: Option<PathBuf>, includefolders: &[PathBuf], warnings: &mut dyn WarningSink, ) -> Result<Config, Error>
Reads the unrapified config from input, preprocessing it.
path is the path to the input if it is known and is used for relative includes and error
messages. includefolders are the folders searched recursively for absolute includes.
§Errors
Returns an error on preprocessing or parse failures.
Sourcepub fn read_in<I: Read>(
input: &mut I,
path: Option<PathBuf>,
includefolders: &IncludeFolders,
warnings: &mut dyn WarningSink,
) -> Result<Config, Error>
pub fn read_in<I: Read>( input: &mut I, path: Option<PathBuf>, includefolders: &IncludeFolders, warnings: &mut dyn WarningSink, ) -> Result<Config, Error>
Like Config::read, with the include folders given as an IncludeFolders (some of them can be checked
directly instead of searched recursively).
§Errors
Returns an error on preprocessing or parse failures.
Sourcepub fn from_string(
input: String,
path: Option<PathBuf>,
includefolders: &[PathBuf],
warnings: &mut dyn WarningSink,
) -> Result<Config, Error>
pub fn from_string( input: String, path: Option<PathBuf>, includefolders: &[PathBuf], warnings: &mut dyn WarningSink, ) -> Result<Config, Error>
Preprocesses and parses input string.
path is the path to the input if it is known and is used for relative includes and error
messages. includefolders are the folders searched recursively for absolute includes.
§Errors
Returns an error on preprocessing or parse failures.
Sourcepub fn from_string_in(
input: String,
path: Option<PathBuf>,
includefolders: &IncludeFolders,
warnings: &mut dyn WarningSink,
) -> Result<Config, Error>
pub fn from_string_in( input: String, path: Option<PathBuf>, includefolders: &IncludeFolders, warnings: &mut dyn WarningSink, ) -> Result<Config, Error>
Like Config::from_string, with the include folders given as an IncludeFolders.
§Errors
Returns an error on preprocessing or parse failures.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Config
impl RefUnwindSafe for Config
impl Send for Config
impl Sync for Config
impl Unpin for Config
impl UnsafeUnpin for Config
impl UnwindSafe for Config
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more