All cloud providers are on by default, to specify a single provider e.g aws:
toml
[dependencies]
waihona={version = "0.0.3", features = ["aws"], default-features = false }
Rust library for cloud storage across major cloud providers It aims to provide simple to use functions to perform CRUD operations on buckets and blobs. Waihona simply means storage in Hawaiian
## Feature Flags
The following feature flags exist for this crate
- [x] aws
: Enable aws provider and dependencies
- [x] gcp
: Enable gcp provider and dependencies
- [x] azure
: Enable azure provider and dependencies
## Traits
Three major traits control behaviour for each provider
Buckets -> Bucket -> Blob
```rust // all methods of traits are async use bytes::Bytes;
trait Buckets , P: Blob{
fn open(&mut self, bucketname: &str);
fn create(&mut self, bucketname: &str, location: Option trait Bucket
where P: Blob{
fn listblobs(&self, marker: Option trait Blob {
fn delete(&self);
fn copy(&self, blobdestinationpath: &str, content_type: Option ``` These quick examples will show you how to make use of the
library for basic actions List buckets from project waihona on GCP ```rust
// ensure to export service credential using GOOGLEAPPLICATIONCREDENTIALS use waihona::providers::gcp::GcpBucket; async fn testlistbuckets() -> Vec Check bucket waihona exists on AWS ```rust async fn testbucketexists() -> bool {
use waihona::types::bucket::{Buckets};
use waihona::providers;
let mut awsbuckets = providers::aws::AwsBuckets::new(
"us-east-2"
);
let resp = awsbuckets.exists(
"waihona"
).await;
// OR you can do
let resp = providers::aws::AwsBucket::exists(
"us-east-2",
"waihona"
).await;
resp
}
``` Write content to a blob "example.txt" in waihona bucket on Azure ```rust use waihona::providers::azure::AzureBlob; async fn testcreateblob() -> AzureBlob {
use waihona::types::bucket::{Buckets, Bucket};
use waihona::types::blob::{Blob};
use waihona::providers;
use bytes::Bytes;
let mut azurebuckets = providers::azure::AzureBuckets::new("waihona".toowned());
let waihona = azurebuckets.open(
"waihona",
).await.unwrap();
let mut blob = waihona.writeblob(
"example.txt",
Some(Bytes::from("Hello world"))
).await
.unwrap();
let read = blob.read().await.unwrap();
assert!(read.eq(&Bytes::from("Hello world")));
}
``` Copy file content from "example.txt" blob on AWS to blob on GCP
and delete AWS blob afterwards
assuming waihona buckets exist on both platforms ```rust use waihona::providers::gcp::GcpBlob; async fn testtransferblob() -> GcpBlob {
use waihona::types::bucket::{Buckets, Bucket};
use waihona::types::blob::{Blob};
use waihona::providers;
use bytes::Bytes;
let mut awsblob = providers::aws::AwsBlob::get(
"us-east-2", // Region
"waihona", // Bucket name
"example.txt", // Blob name
None // Content range
).await
.unwrap();
let mut gcpblob = providers::gcp::GcpBlob::get(
"gcp-project-name", // Project name
"waihona", // Bucket name
"example.txt", // Blob name
None // Content range
).await
.unwrap();
let content: Bytes = awsblob.read().unwrap();
gcpblob.write(Some(content)).await.unwrap();
awsblob.delete().unwrap();
gcpblob
}
``` This project is opened under the MIT License which allows very broad use for both academic and commercial purposesExamples
[cfg(feature = "gcp")]
[tokio::test]
[cfg(feature = "gcp")]
[tokio::test]
[cfg(feature = "aws")]
[cfg(feature = "azure")]
[tokio::test]
[cfg(feature = "azure")]
[cfg(feature = "gcp")]
[tokio::test]
[cfg(all(feature = "gcp", feature = "aws" ))]
License