Struct ConfigSectionSettings

Source
pub struct ConfigSectionSettings { /* private fields */ }
Expand description

Represents the options when creating a new config section.

Implementations§

Source§

impl ConfigSectionSettings

Source

pub fn new<P: Into<String>>(name: P) -> Self

Create a new config section info. This can be passed to a config which will create a new ConfigSection.

#Arguments

  • name - The name that the section should get.
Source

pub fn set_read_callback(self, callback: impl SectionReadCallback) -> Self

Set the function that will be called when an option from the section is read from the disk.

#Arguments

  • callback - The callback for a section read operation.
§Examples
use weechat::Weechat;
use weechat::config::{Conf, ConfigSection, ConfigSectionSettings, OptionChanged};

let server_section_options = ConfigSectionSettings::new("server")
    .set_read_callback(|_: &Weechat, config: &Conf, section: &mut ConfigSection,
                        option_name: &str, option_value: &str| {
        Weechat::print("Writing section");
        OptionChanged::Changed
});
Source

pub fn set_write_callback( self, callback: impl FnMut(&Weechat, &Conf, &mut ConfigSection) + 'static, ) -> Self

Set the function that will be called when the section is being written to the file.

#Arguments

  • callback - The callback for the section write operation.
§Examples
use weechat::Weechat;
use weechat::config::ConfigSectionSettings;

let server_section_options = ConfigSectionSettings::new("server")
    .set_write_callback(|weechat, config, section| {
        Weechat::print("Writing section");
});
Source

pub fn set_write_default_callback( self, callback: impl FnMut(&Weechat, &Conf, &mut ConfigSection) + 'static, ) -> Self

Set the function that will be called when default values will need to be written to to the file.

#Arguments

  • callback - The callback for the section write default operation.

Trait Implementations§

Source§

impl Default for ConfigSectionSettings

Source§

fn default() -> ConfigSectionSettings

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.