Skip to main content

Ini

Struct Ini 

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

a settings object (one thread at a time)

Implementations§

Source§

impl Ini

Source

pub fn new() -> Ini

Source

pub fn load(path: &str) -> Ini

the parsed file; empty when it is missing or unreadable [ini_load]

Source

pub fn load_checked(path: &str) -> Option<Ini>

like load, but None when the file exists and could not be read completely (unreadable or longer than FILE_MAX); a missing or empty file gives an empty Ini

Source

pub fn parse(data: &[u8]) -> Ini

parse settings text [ini_parse]

Source

pub fn to_bytes(&self) -> Vec<u8> ⓘ

the text save writes

Source

pub fn save(&self, path: &str) -> bool

Write through plat::write_file; missing directories are created. [ini_save]

Source

pub fn section(&self, sec: &str) -> Vec<(&str, &str)>

every key of a section with its value, in file order (entries that are not UTF-8 are left out; sec “” = the keys before the first header)

Source

pub fn sections(&self) -> Vec<&str>

the names of the sections in file order, each once (names that are not UTF-8 are left out; the keys before the first header are not a section here)

Source

pub fn items(&self) -> Vec<Item<'_>>

every header, key and malformed line in file order with its line number; blank lines and comments are left out

Source

pub fn get(&self, sec: &str, key: &str) -> Option<&str>

the value, or None when missing or not UTF-8 [ini_get]

Source

pub fn get_bytes(&self, sec: &str, key: &str) -> Option<&[u8]>

Source

pub fn get_int(&self, sec: &str, key: &str, def: i64) -> i64

[ini_get_int]

Source

pub fn get_f64(&self, sec: &str, key: &str, def: f64) -> f64

the whole value must be the number [ini_get_f64]

Source

pub fn set(&mut self, sec: &str, key: &str, value: &str) -> bool

add or replace (false: a bad name) [ini_set]

Source

pub fn set_int(&mut self, sec: &str, key: &str, value: i64) -> bool

[ini_set_int]

Source

pub fn set_f64(&mut self, sec: &str, key: &str, value: f64) -> bool

the shortest text that reads back to the same double [ini_set_f64]

Source

pub fn remove(&mut self, sec: &str, key: &str) -> bool

false: not there [ini_remove]

Trait Implementations§

Source§

impl Default for Ini

Source§

fn default() -> Self

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

Auto Trait Implementations§

§

impl Forget for Ini

§

impl Freeze for Ini

§

impl RefUnwindSafe for Ini

§

impl Send for Ini

§

impl Sync for Ini

§

impl Unpin for Ini

§

impl UnsafeUnpin for Ini

§

impl UnwindSafe for Ini

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 = !

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

fn try_from(value: U) -> Result<T, !>

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.