Struct App

Source
pub struct App {
    pub path: Option<String>,
    pub data: Vec<AppData>,
    pub keys: Vec<String>,
    /* private fields */
}
Expand description

主控制器

§Examples

use file_sql::*;
let app = App::from_file("example.fql");

Fields§

§path: Option<String>

文件路径

§data: Vec<AppData>

储存数据

§keys: Vec<String>

键名列表

Implementations§

Source§

impl App

Source

pub fn from_file<T: Display>(path: T) -> Result<Self>

加载 fql 文件

Source

pub fn serialize(&self) -> Vec<HashMap<String, Value>>

直接生成可序列化数据

Source

pub fn merge_data(&mut self, data: Vec<AppData>)

Source

pub fn save_at<T: Display>(&self, path: T)

保存文件到指定位置

Source

pub fn create_data(&self) -> AppData

创建空的数据

Source

pub fn init_data(&self, data: &mut AppData)

将指定数据初始化

Source

pub fn save(&self)

保存文件

Trait Implementations§

Source§

impl Clone for App

Source§

fn clone(&self) -> App

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for App

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Editor for App

Source§

fn replace(&mut self, index: usize, new_data: AppData)

修改一行数据 #Example

 use file_sql::*;
 let app = App::from_file("example.fql");
 let new_data = app.find_index(1);
 app.replace(0, "age", new_data.to_owned());
Source§

fn insert(&mut self, index: usize, new_data: AppData)

在指定一行加入数据

Source§

fn remove(&mut self, index: usize)

删除某一列数据 #Example

 use file_sql::*;
 let app = App::from_file("example.fql");
 app.remove(1); // 删除第二行数据
Source§

fn add(&mut self, new_data: AppData)

添加数据到末尾

Source§

fn update<T: Display>(&mut self, index: usize, key: T, new_value: FQLType)

Source§

impl From<&str> for App

Source§

fn from(s: &str) -> Self

Converts to this type from the input type.
Source§

impl From<Vec<&AppData>> for App

Source§

fn from(data: Vec<&AppData>) -> Self

Converts to this type from the input type.
Source§

impl From<Vec<AppData>> for App

Source§

fn from(data: Vec<AppData>) -> Self

Converts to this type from the input type.
Source§

impl From<Vec<String>> for App

Source§

fn from(lines: Vec<String>) -> Self

Converts to this type from the input type.
Source§

impl Into<Vec<Vec<FQLType>>> for App

Source§

fn into(self) -> Vec<Vec<FQLType>>

Converts this type into the (usually inferred) input type.
Source§

impl Reader for App

Source§

fn index(&self, index: usize) -> Option<&AppData>

查找指定序号的数据

Source§

fn find<T: Display>(&self, key: T, val: FQLType) -> Option<&AppData>

查找第一个符合条件的数据

Source§

fn find_index<T: Display>(&self, key: T, val: FQLType) -> Option<usize>

查找第一个符合条件的数据的序号

Source§

fn find_all<T: Display>(&self, key: T, val: FQLType) -> Vec<&AppData>

获取所有符合条件的数据

Source§

fn find_all_index<T: Display>(&self, key: T, val: FQLType) -> Vec<usize>

获取所有符合条件的数据序号

Source§

fn find_by<T: Display>( &self, key: T, f: impl Fn(&FQLType) -> bool, ) -> Vec<&AppData>

获取所有符合过滤函数的数据

Source§

fn find_index_by<T: Display>( &self, key: T, f: impl Fn(&FQLType) -> bool, ) -> Vec<usize>

Source§

fn find_index_from_data(&self, data: &AppData) -> Option<usize>

Auto Trait Implementations§

§

impl Freeze for App

§

impl RefUnwindSafe for App

§

impl Send for App

§

impl Sync for App

§

impl Unpin for App

§

impl UnwindSafe for App

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.