Struct TNT

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

Implementations§

Source§

impl TNT

Source

pub fn connect(filename: &str) -> Self

Создаёт новый экземпляр TNT, ассоциированный с указанным файлом. Если файл не существует, он будет создан.

§Аргументы
  • filename - Имя файла для хранения данных.
§Пример
let tnt = TNT::connect("data.txt");

Creates a new TNT instance associated with the specified file. If the file does not exist, it will be created.

§Arguments
  • filename - The name of the file to store data.
§Example
let tnt = TNT::connect("data.txt");
Source

pub fn add<T: Display, V: Display>( &self, key: &str, var: T, val: V, ) -> Result<()>

Добавляет новую переменную с указанным значением в секцию ключа. Если ключа нет, он будет создан. Если переменная уже существует, операция не выполнится.

§Аргументы
  • key - Имя секции (ключа)
  • var - Имя переменной
  • val - Значение переменной

Adds a new variable with the specified value to the key section. If the key does not exist, it will be created. If the variable already exists, the operation will not be performed.

§Arguments
  • key - Section (key) name
  • var - Variable name
  • val - Variable value
Source

pub fn get<T: Display>(&self, key: &str, var: T) -> Result<String>

Получает значение переменной по ключу и имени переменной. Если переменная не найдена, возвращает “NONE_VAL”.

§Аргументы
  • key - Имя секции (ключа)
  • var - Имя переменной

Gets the value of a variable by key and variable name. If the variable is not found, returns “NONE_VAL”.

§Arguments
  • key - Section (key) name
  • var - Variable name
Source

pub fn edit<T: Display, V: Display>( &self, key: &str, var: T, new_val: V, ) -> Result<()>

Изменяет значение переменной в секции ключа. Если переменная не найдена, операция не выполнится.

§Аргументы
  • key - Имя секции (ключа)
  • var - Имя переменной
  • new_val - Новое значение переменной

Edits the value of a variable in the key section. If the variable is not found, the operation will not be performed.

§Arguments
  • key - Section (key) name
  • var - Variable name
  • new_val - New value for the variable
Source

pub fn delete_var<T: Display>(&self, key: &str, var: T) -> Result<()>

Удаляет переменную из секции ключа. Если переменная не найдена, операция не выполнится.

§Аргументы
  • key - Имя секции (ключа)
  • var - Имя переменной

Deletes a variable from the key section. If the variable is not found, the operation will not be performed.

§Arguments
  • key - Section (key) name
  • var - Variable name
Source

pub fn delete_key(&self, key: &str) -> Result<()>

Удаляет секцию (ключ) и все переменные внутри неё. Если ключ не найден, операция не выполнится.

§Аргументы
  • key - Имя секции (ключа)

Deletes a section (key) and all variables inside it. If the key is not found, the operation will not be performed.

§Arguments
  • key - Section (key) name
Source

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

Очищает весь файл, удаляя все данные.

Clears the entire file, removing all data.

Source

pub fn get_all(&self, key: &str) -> Result<Vec<String>>

Получает все значения переменных в секции ключа.

§Аргументы
  • key - Имя секции (ключа)

Gets all variable values in the key section.

§Arguments
  • key - Section (key) name
Source

pub fn to_toml(&self, filename: &str) -> Result<()>

Экспортирует данные в формате TOML в указанный файл.

§Аргументы
  • filename - Имя файла (без расширения), куда будет сохранён TOML.

Exports data in TOML format to the specified file.

§Arguments
  • filename - File name (without extension) where TOML will be saved.
Source

pub fn to_json(&self, filename: &str) -> Result<()>

Экспортирует данные в формате JSON в указанный файл.

§Аргументы
  • filename - Имя файла (без расширения), куда будет сохранён JSON.

Exports data in JSON format to the specified file.

§Arguments
  • filename - File name (without extension) where JSON will be saved.
Source

pub fn from_toml(&self, toml: &str) -> Result<()>

Импортирует данные из TOML-файла в основной файл.

§Аргументы
  • toml - Имя TOML-файла (без расширения), из которого будут импортированы данные.

Imports data from a TOML file into the main file.

§Arguments
  • toml - TOML file name (without extension) from which data will be imported.
Source

pub fn from_json(&self, json: &str) -> Result<()>

Импортирует данные из JSON-файла в основной файл.

§Аргументы
  • json - Имя JSON-файла (без расширения), из которого будут импортированы данные.

Imports data from a JSON file into the main file.

§Arguments
  • json - JSON file name (without extension) from which data will be imported.

Auto Trait Implementations§

§

impl Freeze for TNT

§

impl RefUnwindSafe for TNT

§

impl Send for TNT

§

impl Sync for TNT

§

impl Unpin for TNT

§

impl UnwindSafe for TNT

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.