| Crates.io | unofficial_appwrite |
| lib.rs | unofficial_appwrite |
| version | 1.0.0 |
| created_at | 2024-04-13 11:28:46.700163+00 |
| updated_at | 2025-01-03 21:44:33.966045+00 |
| description | wrapper on appwrite api -> https://appwrite.io/docs |
| homepage | https://github.com/ahmad-olu/un-official-appwrite-rust-sdk |
| repository | https://github.com/ahmad-olu/un-official-appwrite-rust-sdk |
| max_upload_size | |
| id | 1207513 |
| size | 435,820 |
This SDK is compatible with Appwrite server version 1.5.x. This is the Rust SDK for integrating with Appwrite from your Rust server-side code
Appwrite is an open-source backend as a service server that abstract and simplify complex and repetitive development tasks behind a very simple to use REST API. Appwrite aims to help you develop your apps faster and in a more secure way. Use the Rust to integrate your app with the Appwrite server to easily start interacting with all of Appwrite backend APIs and tools. For full API documentation and tutorials go to https://appwrite.io/docs
Once you add the dependencies, its extremely easy to get started with the SDK; All you need to do is import the package in your code, set your Appwrite credentials, and start making API calls. Below is a simple example:
use unofficial_appwrite::client::ClientBuilder;
use unofficial_appwrite::error::Error;
use unofficial_appwrite::services::server::users::Users;
use unofficial_appwrite::id::ID;
#[tokio::main]
async fn main() -> Result<(), Error> {
let client = ClientBuilder::default()
.set_endpoint("http://[HOSTNAME_OR_IP]/v1") // Make sure your endpoint is accessible
.set_project("5ff...")? // Your project ID
.set_key("cd868c7af8bdc893b4...93b7535db89")?
//.set_self_signed(false)? // Use only on dev mode with a self-signed SSL cert
.build()?;
//create new user
let create = Users::create(
&client,
maplit::hashmap! {
"userId".into() => ID::unique(7).into(),
"email".into()=> "fakeEmail@Email.com".into(),
"password".into()=> "VeryVerySecurePassword@123456789".into(),
"name".into()=> "fakeEmail".into()
},
)
.await?;
assert_eq!(create.email, "fakeemail@email.com");
}
https://github.com/ahmad-olu/un-official-appwrite-rust-sdkuse unofficial_appwrite::client::ClientBuilder;
use unofficial_appwrite::error::Error;
use unofficial_appwrite::id::ID;
use unofficial_appwrite::services::server::storage::Storage;
use futures_util::{pin_mut, StreamExt};
use std::fs;
#[tokio::main]
async fn main() -> Result<(), Error> {
let client = ClientBuilder::default()
.set_endpoint("http://[HOSTNAME_OR_IP]/v1") // Make sure your endpoint is accessible
.set_project("5ff3379a01d25")? // Your project ID
.set_key("cd868c7af8bdc893b4...93b7535db89")?
//.set_self_signed(false)? // Use only on dev mode with a self-signed SSL cert
.build()?;
// create a file without getting upload progress
let id = ID::unique_old().into();
let create_file = Storage::create_files(
&client,
"6773f8af000602e81619".to_string(),
id,
file_path.to_string(),
file_name.to_string(),
HashMap::<String, Value>::new(),
|progress| {
println!(
"Uploaded: {}/{} ({}%), ID: {}",
progress.size_uploaded,
(progress.chunks_total as usize) * progress.size_uploaded, // Approximate total size
(progress.progress * 100.0).round(),
progress.id,
);
},
)
.await?;
dbg!(create_file);
}
use futures_util::{pin_mut, StreamExt};
use unofficial_appwrite::{client::ClientBuilder, error::Error, realtime::RealTime};
#[tokio::main]
async fn main() -> Result<(), Error> {
let client = ClientBuilder::default()
.set_endpoint("http://[HOSTNAME_OR_IP]/v1") // Make sure your endpoint is accessible
.set_project("5ff3...")? // Your project ID
.set_key("cd868c7af8bdc893b4...93b7535db89")?
//.set_self_signed(false)? // Use only on dev mode with a self-signed SSL cert
.build()?;
// subscribe to realtime
let stream = RealTime::subscribe(
&client,
vec!["databases.6618eec286a4ef198076.collections.6618ef06d269bf4110d4.documents"],
)
.await;
pin_mut!(stream);
while let Some(data) = stream.next().await {
println!("=====>{:?}<=====", data);
}
}
unofficial_appwrite::query::Query::equal("title".into(), vec!["bamboo", "ace"].into());
unofficial_appwrite::query::Query::less_than("score".into(), 10.into());
unofficial_appwrite::query::Query::or(
vec![
unofficial_appwrite::query::Query::less_than("size".into(), 5.into()),
unofficial_appwrite::query::Query::greater_than("size".into(), 10.into())
]
.into()
);
use unofficial_appwrite::id::ID;
ID::unique(7).into();
//or
ID::unique_old().into();
use unofficial_appwrite::permission::Permission;
Permission::read("any"),
Permission::create("user:22222346"),
use unofficial_appwrite::role::Role;
Role::any()
NOTE: for other examples. check out the official docs or sdk of official sdk as a guide to using this sdk.
You can use the following resources to learn more and get help
unofficial-apperite_rust-sdkThe latest version of the unofficial-apperite_rust-sdk introduces significant API updates to address two primary goals:
pub async fn create(
client: &Client,
function_id: &str,
name: &str,
runtime: Runtime,
execute: Option<Vec<&str>>,
events: Option<Vec<&str>>,
schedule: Option<&str>,
timeout: Option<u64>,
enabled: Option<bool>,
logging: Option<bool>,
entry_point: Option<&str>,
commands: Option<&str>,
installation_id: Option<&str>,
provider_repository_id: Option<&str>,
provider_branch: Option<&str>,
provider_silent_mode: Option<bool>,
provider_root_directory: Option<&str>,
template_repository: Option<&str>,
template_owner: Option<&str>,
template_root_directory: Option<&str>,
template_branch: Option<&str>,
) -> Result<Func, Error> { ... }
Now, instead of this "polluted" approach, the new API allows you to pass required and optional parameters as a HashMap:
pub async fn create(client: &Client, args: HashMap<String, Value>) -> Result<Func, Error> { ... }
To pass parameters, use a HashMap with the required keys and values. Required parameters are documented as * parameterName => type, and optional ones are indicated by a ?, like * timeout => number?. Examples of parameter types include:
string for text valuesnumber for integersfloats for floatbool for boolean valuesvec(string) or list(string) for vectors
Hereβs an example usage:maplit::hashmap! {
"userId".into() => ID::unique(7).into(),
"email".into() => "fakeEmailAcc@Email.com".into(),
"password".into() => "VerySecurePassword123!".into(),
}
The new API introduces improved ID handling, but backward compatibility is maintained:
ID::unique(7).into() for the updated API.ID::unique_old().into() where required, such as with Storage::create_files(...), until the upload file functionality is refactored.
The goal is to ensure a smoother development experience while maintaining backward compatibility during the transition.