Struct Config

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

Weechat configuration file

Implementations§

Source§

impl Config

Source

pub fn new(name: &str) -> Result<Config, ()>

Create a new Weechat configuration file, returns a Config object. The configuration file is freed when the Config object is dropped.

§Arguments
  • name - Name of the new configuration file
§Panics

Panics if the method is not called from the main Weechat thread.

Source

pub fn new_with_callback( name: &str, reload_callback: impl ConfigReloadCallback, ) -> Result<Config, ()>

Create a new Weechat configuration file, returns a Config object. The configuration file is freed when the Config object is dropped.

§Arguments
  • name - Name of the new configuration file

  • reload_callback - Callback that will be called when the configuration file is reloaded.

§Examples
use weechat::Weechat;
use weechat::config::{Conf, Config};

let config = Config::new_with_callback("server_buffer",
    |weechat: &Weechat, conf: &Conf| {
        Weechat::print("Config was reloaded");
    }
);
§Panics

Panics if the method is not called from the main Weechat thread.

Source

pub fn read(&self) -> Result<()>

Read the configuration file from the disk.

Source

pub fn write(&self) -> Result<()>

Write the configuration file to the disk.

Source

pub fn new_section( &mut self, section_settings: ConfigSectionSettings, ) -> Result<SectionHandleMut<'_>, ()>

Create a new section in the configuration file.

§Arguments
  • section_settings - Settings that decide how the section will be created.
§Panics

Panics if the method is not called from the main Weechat thread.

Source

pub fn search_section(&self, section_name: &str) -> Option<SectionHandle<'_>>

Search the configuration object for a section and borrow it.

Returns a handle to a section if one is found, None otherwise.

§Arguments
  • section_name - The name of the section that should be retrieved.
§Panics

This will panic if it is being called in a section read/write callback of the same section that is being retrieved or if the section is already mutably borrowed.

Source

pub fn search_section_mut( &mut self, section_name: &str, ) -> Option<SectionHandleMut<'_>>

Search the configuration object for a section and borrow it mutably.

Returns a handle to a section if one is found, None otherwise.

§Arguments
  • section_name - The name of the section that should be retrieved.
§Panics

This will panic if it is being called in a section read/write callback of the same section that is being retrieved or if the section is already borrowed.

Trait Implementations§

Source§

impl Drop for Config

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

§

impl Freeze for Config

§

impl !RefUnwindSafe for Config

§

impl !Send for Config

§

impl !Sync for Config

§

impl Unpin for Config

§

impl !UnwindSafe for Config

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.