Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions app/config/sdks.php
Original file line number Diff line number Diff line change
Expand Up @@ -494,6 +494,25 @@
'gitBranch' => 'dev',
'changelog' => \realpath(__DIR__ . '/../../docs/sdks/swift/CHANGELOG.md'),
],
[
'key' => 'rust',
'name' => 'Rust',
'version' => '0.1.0',
'url' => 'https://github.com/appwrite/sdk-for-rust',
'package' => 'https://crates.io/crates/appwrite',
'enabled' => true,
'beta' => true,
'dev' => true,
'hidden' => false,
'family' => APP_SDK_PLATFORM_SERVER,
'prism' => 'rust',
'source' => \realpath(__DIR__ . '/../sdks/server-rust'),
'gitUrl' => '[email protected]:appwrite/sdk-for-rust.git',
'gitRepoName' => 'sdk-for-rust',
'gitUserName' => 'appwrite',
'gitBranch' => 'dev',
'changelog' => \realpath(__DIR__ . '/../../docs/sdks/rust/CHANGELOG.md'),
],
[
'key' => 'graphql',
'name' => 'GraphQL',
Expand Down
78 changes: 39 additions & 39 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions docs/sdks/rust/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Change Log

## 0.1.0

* Initial release
68 changes: 68 additions & 0 deletions docs/sdks/rust/GETTING_STARTED.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
## 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.

```rust
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](https://appwrite.io/docs) section.

```rust
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 protected]"),
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.

```rust
use appwrite::error::AppwriteError;

match users.create(
ID::unique(),
Some("[email protected]"),
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
- 🚀 [Getting Started Tutorial](https://appwrite.io/docs/getting-started-for-server)
- 📜 [Appwrite Docs](https://appwrite.io/docs)
- 💬 [Discord Community](https://appwrite.io/discord)
6 changes: 0 additions & 6 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -594,12 +594,6 @@ parameters:
count: 1
path: src/Appwrite/Platform/Modules/Databases/Http/Databases/Transactions/Update.php

-
message: '#^Variable \$currentDocumentId on left side of \?\? always exists and is always null\.$#'
identifier: nullCoalesce.variable
count: 1
path: src/Appwrite/Platform/Modules/Databases/Http/Databases/Transactions/Update.php

-
message: '#^Offset ''deviceBrand'' does not exist on int\.$#'
identifier: offsetAccess.notFound
Expand Down
4 changes: 4 additions & 0 deletions src/Appwrite/Platform/Tasks/SDKs.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
use Appwrite\SDK\Language\ReactNative;
use Appwrite\SDK\Language\REST;
use Appwrite\SDK\Language\Ruby;
use Appwrite\SDK\Language\Rust;
use Appwrite\SDK\Language\Swift;
use Appwrite\SDK\Language\Web;
use Appwrite\SDK\SDK;
Expand Down Expand Up @@ -301,6 +302,9 @@ public function action(?string $platform, ?string $sdk, ?string $version, ?strin
$config = new Kotlin();
$warning = $warning . "\n\n > This is the Kotlin SDK for integrating with Appwrite from your Kotlin server-side code. If you're looking for the Android SDK you should check [appwrite/sdk-for-android](https://github.com/appwrite/sdk-for-android)";
break;
case 'rust':
$config = new Rust();
break;
case 'graphql':
$config = new GraphQL();
break;
Expand Down
Loading