Builder

Struct Builder 

Source
pub struct Builder { /* private fields */ }

Implementations§

Source§

impl Builder

Source

pub fn with_config(config: Config) -> Self

Creates a config file builder based on a Config.

Examples found in repository?
examples/ready_made_components.rs (lines 4-8)
3fn main() {
4    let mut config_builder = Builder::with_config(Config {
5        name: String::from("my_gsi_config_file"),
6        data: Components::ALL.into(),
7        ..Default::default()
8    });
9    config_builder
10        .build()
11        .install("C:\\Counter-Strike Global Offensive\\csgo\\cfg")
12        .unwrap();
13}
More examples
Hide additional examples
examples/own_set_components.rs (lines 8-12)
6fn main() {
7    let components: &[Components] = &[Components::Provider, Components::PlayerId];
8    let mut config_builder = Builder::with_config(Config {
9        name: String::from("my_gsi_config_file"),
10        data: Data::from(components),
11        ..Default::default()
12    });
13    config_builder
14        .build()
15        .install("C:\\Counter-Strike Global Offensive\\csgo\\cfg")
16        .unwrap();
17}
Source

pub fn build(&mut self) -> &mut Self

Serializes the Config to a string ready to be written in a cfg file.

Examples found in repository?
examples/ready_made_components.rs (line 10)
3fn main() {
4    let mut config_builder = Builder::with_config(Config {
5        name: String::from("my_gsi_config_file"),
6        data: Components::ALL.into(),
7        ..Default::default()
8    });
9    config_builder
10        .build()
11        .install("C:\\Counter-Strike Global Offensive\\csgo\\cfg")
12        .unwrap();
13}
More examples
Hide additional examples
examples/own_set_components.rs (line 14)
6fn main() {
7    let components: &[Components] = &[Components::Provider, Components::PlayerId];
8    let mut config_builder = Builder::with_config(Config {
9        name: String::from("my_gsi_config_file"),
10        data: Data::from(components),
11        ..Default::default()
12    });
13    config_builder
14        .build()
15        .install("C:\\Counter-Strike Global Offensive\\csgo\\cfg")
16        .unwrap();
17}
Source

pub fn output(&self) -> String

Gets the serialized Config.

This method must only be called after build.

Source

pub fn install<P: Into<PathBuf>>( &self, folder_path: P, ) -> Result<(), Box<dyn Error>>

Write the serialized Config to a cfg file at the path passed in argument.

Examples found in repository?
examples/ready_made_components.rs (line 11)
3fn main() {
4    let mut config_builder = Builder::with_config(Config {
5        name: String::from("my_gsi_config_file"),
6        data: Components::ALL.into(),
7        ..Default::default()
8    });
9    config_builder
10        .build()
11        .install("C:\\Counter-Strike Global Offensive\\csgo\\cfg")
12        .unwrap();
13}
More examples
Hide additional examples
examples/own_set_components.rs (line 15)
6fn main() {
7    let components: &[Components] = &[Components::Provider, Components::PlayerId];
8    let mut config_builder = Builder::with_config(Config {
9        name: String::from("my_gsi_config_file"),
10        data: Data::from(components),
11        ..Default::default()
12    });
13    config_builder
14        .build()
15        .install("C:\\Counter-Strike Global Offensive\\csgo\\cfg")
16        .unwrap();
17}

Trait Implementations§

Source§

impl Default for Builder

Source§

fn default() -> Builder

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.