Skip to content

appwrite/sdk-for-rust

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Appwrite Rust SDK

License Version Crates.io Documentation

This SDK is compatible with Appwrite server version 1.8.x. For older versions, please check previous releases.

Appwrite is an open-source backend as a service server that abstracts and simplifies 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 SDK 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

Appwrite

Installation

Add this to your Cargo.toml:

[dependencies]
appwrite = "0.1.0"
tokio = { version = "1.48", features = ["full"] }

Or using cargo add:

cargo add appwrite

Getting Started

Init your SDK

Initialize your SDK with your Appwrite server API endpoint and project ID which can be found on your project settings page and your new API secret Key from project's API keys section.

use appwrite::client::Client;

let client = Client::new()
    .set_endpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint
    .set_project("5df5acd0d48c2") // Your project ID
    .set_key("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key
    .set_self_signed(true); // Use only on dev mode with a self-signed SSL cert

Make Your First Request

Once your SDK object is set, create any of the Appwrite service objects and choose any request to send. Full documentation for any service method you would like to use can be found in your SDK documentation or in the API References section.

use appwrite::client::Client;
use appwrite::services::users::Users;
use appwrite::id::ID;

let client = Client::new()
    .set_endpoint("https://[HOSTNAME_OR_IP]/v1")
    .set_project("5df5acd0d48c2")
    .set_key("919c2d18fb5d4...a2ae413da83346ad2")
    .set_self_signed(true);

let users = Users::new(&client);

let user = users.create(
    ID::unique(),
    Some("email@example.com"),
    Some("+123456789"),
    Some("password"),
    Some("Walter O'Brien"),
).await?;

println!("{}", user.name);
println!("{}", user.email);

Error Handling

The Appwrite Rust SDK returns Result types. You can handle errors using standard Rust error handling patterns. Below is an example.

use appwrite::error::AppwriteError;

match users.create(
    ID::unique(),
    Some("email@example.com"),
    Some("+123456789"),
    Some("password"),
    Some("Walter O'Brien"),
).await {
    Ok(user) => println!("{}", user.name),
    Err(AppwriteError { message, code, .. }) => {
        eprintln!("Error {}: {}", code, message);
    }
}

Learn more

You can use the following resources to learn more and get help

Contribution

This library is auto-generated by Appwrite custom SDK Generator. To learn more about how you can help us improve this SDK, please check the contribution guide before sending a pull-request.

License

Please see the BSD-3-Clause license file for more information.

About

[READ-ONLY] Official Appwrite Rust SDK ⚙️

Topics

Resources

License

Code of conduct

Contributing

Security policy

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages