pub trait SetGet {
// Required methods
fn get_string(&self, cvar_name: &str) -> Result<String, String>;
fn set_str(
&mut self,
cvar_name: &str,
str_value: &str
) -> Result<(), String>;
fn cvar_count(&self) -> usize;
}Expand description
A trait for writing generic code that can access cvars but doesn’t know the concrete Cvars struct.
This is implemented automatically by both #[derive(SetGet)] and cvars! {}.
The methods provided here call those implemented directly on the concrete Cvars struct, there is no difference between them.
Implementation note: This trait can’t include the get and set methods
because it would no longer be object-safe.
Required Methods§
sourcefn get_string(&self, cvar_name: &str) -> Result<String, String>
fn get_string(&self, cvar_name: &str) -> Result<String, String>
Finds the cvar whose name matches cvar_name and returns it’s value as a String.
Returns Err if the cvar doesn’t exist.
sourcefn set_str(&mut self, cvar_name: &str, str_value: &str) -> Result<(), String>
fn set_str(&mut self, cvar_name: &str, str_value: &str) -> Result<(), String>
Finds the cvar whose name matches cvar_name, tries to parse str_value to its type and sets it to the parsed value.
Returns Err if the cvar doesn’t exist or if str_value fails to parse to its type.
sourcefn cvar_count(&self) -> usize
fn cvar_count(&self) -> usize
Returns the number of cvars.