pub struct TNT { /* private fields */ }Implementations§
Source§impl TNT
impl TNT
Sourcepub fn connect(filename: &str) -> Self
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");Sourcepub fn add<T: Display, V: Display>(
&self,
key: &str,
var: T,
val: V,
) -> Result<()>
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) namevar- Variable nameval- Variable value
Sourcepub fn get<T: Display>(&self, key: &str, var: T) -> Result<String>
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) namevar- Variable name
Sourcepub fn edit<T: Display, V: Display>(
&self,
key: &str,
var: T,
new_val: V,
) -> Result<()>
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) namevar- Variable namenew_val- New value for the variable
Sourcepub fn delete_var<T: Display>(&self, key: &str, var: T) -> Result<()>
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) namevar- Variable name
Sourcepub fn delete_key(&self, key: &str) -> Result<()>
pub fn delete_key(&self, key: &str) -> Result<()>
Sourcepub fn clear(&self) -> Result<()>
pub fn clear(&self) -> Result<()>
Очищает весь файл, удаляя все данные.
Clears the entire file, removing all data.