pub struct DataClient {
pub http: Client,
pub api_key: String,
pub host: String,
}Expand description
The data client is used to access an app’s data storage capabilities.
Fields§
§http: ClientThe HTTP client associated with this client.
api_key: StringThe app’s API key. You can retrieve this from the web dashboard.
host: StringThe origin of the Tetratto server. When creating with DataClient::new,
you can provide None to use https://tetratto.com.
Implementations§
Source§impl DataClient
impl DataClient
Sourcepub async fn get_app(&self) -> Result<ThirdPartyApp>
pub async fn get_app(&self) -> Result<ThirdPartyApp>
Get the current app using the provided API key.
§Usage
let client = DataClient::new("https://tetratto.com".to_string(), "...".to_string());
let app = client.get_app().await.expect("failed to get app");Sourcepub async fn check_ip(&self, ip: &str) -> Result<bool>
pub async fn check_ip(&self, ip: &str) -> Result<bool>
Check if the given IP is IP banned from the Tetratto host. You will only know if the IP is banned or not, meaning you will not be shown the reason if it is banned.
Sourcepub async fn query(&self, query: &SimplifiedQuery) -> Result<AppDataQueryResult>
pub async fn query(&self, query: &SimplifiedQuery) -> Result<AppDataQueryResult>
Query the app’s data.
Sourcepub async fn insert(&self, key: String, value: String) -> Result<String>
pub async fn insert(&self, key: String, value: String) -> Result<String>
Insert a key, value pair into the app’s data.
Sourcepub async fn update(&self, id: usize, value: String) -> Result<()>
pub async fn update(&self, id: usize, value: String) -> Result<()>
Update a record’s value given its ID and the new value.
Sourcepub async fn rename(&self, id: usize, key: String) -> Result<()>
pub async fn rename(&self, id: usize, key: String) -> Result<()>
Update a record’s key given its ID and the new key.
Sourcepub async fn remove(&self, id: usize) -> Result<()>
pub async fn remove(&self, id: usize) -> Result<()>
Delete a row from the app’s data by its id.
Sourcepub async fn remove_query(&self, query: &AppDataQuery) -> Result<()>
pub async fn remove_query(&self, query: &AppDataQuery) -> Result<()>
Delete row(s) from the app’s data by a query.
Trait Implementations§
Source§impl Clone for DataClient
impl Clone for DataClient
Source§fn clone(&self) -> DataClient
fn clone(&self) -> DataClient
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more