Compare commits

..
Author SHA1 Message Date
phoenix ccad50f414 Update deps (#5)
simodels Build / Rustfmt (push) Successful in 30s
labyrinth release Tagging / release (push) Successful in 24s
simodels Build / Clippy (push) Successful in 1m12s
simodels Build / Check (push) Successful in 1m24s
simodels Build / Test Suite (push) Successful in 1m24s
simodels Build / build (push) Successful in 1m27s
Reviewed-on: http://git.kundeng.us/phoenix/labyrinth/pulls/5
2026-10-30 18:31:49 -04:00
phoenix b9a40a20dd Update rust (#4)
labyrinth release Tagging / release (push) Successful in 38s
simodels Build / build (push) Successful in 52s
simodels Build / Rustfmt (push) Successful in 1m15s
simodels Build / Check (push) Successful in 1m51s
simodels Build / Clippy (push) Successful in 1m52s
simodels Build / Test Suite (push) Successful in 2m15s
Reviewed-on: http://git.kundeng.us/phoenix/labyrinth/pulls/4
2026-10-09 13:00:25 -04:00
phoenix 9f111b5efb bump: labyrinth
labyrinth release Tagging / release (push) Successful in 1m58s
simodels Build / Check (push) Successful in 1m51s
simodels Build / Test Suite (push) Successful in 1m53s
simodels Build / Rustfmt (push) Successful in 1m43s
simodels Build / Clippy (push) Successful in 2m17s
simodels Build / build (push) Successful in 1m48s
2026-08-15 10:26:09 -04:00
phoenix 2b602bded6 cargo update 2026-08-15 10:25:47 -04:00
phoenix 6a780d5baf bump: uuid 2026-08-15 10:25:04 -04:00
phoenix 88d5fa2780 bump: tokio 2026-08-15 10:24:28 -04:00
phoenix 8b2b18f9b5 bump: time 2026-08-15 10:23:47 -04:00
phoenix 8660cd479f bump: aws-sdk-s3 2026-08-15 10:23:11 -04:00
phoenix 9c3e9cd204 bump: aws-config 2026-08-15 10:22:22 -04:00
phoenix f406ed1961 Delete object (#3)
labyrinth release Tagging / release (push) Successful in 1m15s
simodels Build / build (push) Successful in 1m25s
simodels Build / Test Suite (push) Successful in 1m35s
simodels Build / Check (push) Successful in 1m38s
simodels Build / Rustfmt (push) Successful in 2m33s
simodels Build / Clippy (push) Successful in 2m49s
Reviewed-on: http://git.kundeng.us/phoenix/labyrinth/pulls/3
2026-08-11 10:39:12 -04:00
phoenix 6ed1d00a32 Download (#2)
simodels Build / Test Suite (push) Successful in 1m18s
simodels Build / build (push) Successful in 1m21s
simodels Build / Check (push) Successful in 1m25s
labyrinth release Tagging / release (push) Successful in 1m46s
simodels Build / Rustfmt (push) Successful in 1m54s
simodels Build / Clippy (push) Successful in 2m36s
Reviewed-on: http://git.kundeng.us/phoenix/labyrinth/pulls/2
2026-08-10 17:41:33 -04:00
5 changed files with 439 additions and 382 deletions

No files matched your search

+5 -5
View File
@@ -21,7 +21,7 @@ jobs:
- uses: actions/checkout@v6 - uses: actions/checkout@v6
- uses: actions-rust-lang/setup-rust-toolchain@v1 - uses: actions-rust-lang/setup-rust-toolchain@v1
with: with:
toolchain: 1.97 toolchain: 1.99
- uses: Swatinem/rust-cache@v2 - uses: Swatinem/rust-cache@v2
- run: cargo check - run: cargo check
@@ -32,7 +32,7 @@ jobs:
- uses: actions/checkout@v6 - uses: actions/checkout@v6
- uses: actions-rust-lang/setup-rust-toolchain@v1 - uses: actions-rust-lang/setup-rust-toolchain@v1
with: with:
toolchain: 1.97 toolchain: 1.99
- uses: Swatinem/rust-cache@v2 - uses: Swatinem/rust-cache@v2
- run: cargo test - run: cargo test
@@ -43,7 +43,7 @@ jobs:
- uses: actions/checkout@v6 - uses: actions/checkout@v6
- uses: actions-rust-lang/setup-rust-toolchain@v1 - uses: actions-rust-lang/setup-rust-toolchain@v1
with: with:
toolchain: 1.97 toolchain: 1.99
- uses: Swatinem/rust-cache@v2 - uses: Swatinem/rust-cache@v2
- run: rustup component add rustfmt - run: rustup component add rustfmt
- run: cargo fmt --all -- --check - run: cargo fmt --all -- --check
@@ -55,7 +55,7 @@ jobs:
- uses: actions/checkout@v6 - uses: actions/checkout@v6
- uses: actions-rust-lang/setup-rust-toolchain@v1 - uses: actions-rust-lang/setup-rust-toolchain@v1
with: with:
toolchain: 1.97 toolchain: 1.99
- uses: Swatinem/rust-cache@v2 - uses: Swatinem/rust-cache@v2
- run: rustup component add clippy - run: rustup component add clippy
- run: cargo clippy -- -D warnings - run: cargo clippy -- -D warnings
@@ -67,7 +67,7 @@ jobs:
- uses: actions/checkout@v6 - uses: actions/checkout@v6
- uses: actions-rust-lang/setup-rust-toolchain@v1 - uses: actions-rust-lang/setup-rust-toolchain@v1
with: with:
toolchain: 1.97 toolchain: 1.99
- uses: Swatinem/rust-cache@v2 - uses: Swatinem/rust-cache@v2
- run: cargo build - run: cargo build
+1 -1
View File
@@ -20,7 +20,7 @@ jobs:
- name: Install Rust - name: Install Rust
uses: actions-rs/toolchain@v1 uses: actions-rs/toolchain@v1
with: with:
toolchain: 1.97 toolchain: 1.99
components: cargo components: cargo
- uses: Swatinem/rust-cache@v2 - uses: Swatinem/rust-cache@v2
Generated
+375 -365
View File
File diff suppressed because it is too large. Load diff
+6 -6
View File
@@ -1,13 +1,13 @@
[package] [package]
name = "labyrinth" name = "labyrinth"
version = "0.0.2" version = "0.0.7"
edition = "2024" edition = "2024"
license = "MIT" license = "MIT"
description = "Library for managing soaricarus storage" description = "Library for managing soaricarus storage"
[dependencies] [dependencies]
aws-config = { version = "1.9.0", features = ["behavior-version-latest"] } aws-config = { version = "1.13.0", features = ["behavior-version-latest"] }
aws-sdk-s3 = { version = "1.138.1" } aws-sdk-s3 = { version = "1.157.0" }
time = "0.3.53" time = "0.3.55"
tokio = { version = "1.53.0", features = ["full"] } tokio = { version = "1.54.1", features = ["full"] }
uuid = "1.24.0" uuid = "1.27.0"
+52 -5
View File
@@ -37,8 +37,7 @@ pub async fn init_client(config: &config::Config) -> aws_sdk_s3::Client {
.force_path_style(true) .force_path_style(true)
.build(); .build();
let client = aws_sdk_s3::Client::from_conf(s3_config); aws_sdk_s3::Client::from_conf(s3_config)
client
} }
#[derive(Debug)] #[derive(Debug)]
@@ -48,16 +47,17 @@ pub enum Error {
} }
impl Labyrinth { impl Labyrinth {
/// Upload object to the bucket
pub async fn upload( pub async fn upload(
&self, &self,
file_key: &str, file_key: &str,
data: &Data, data: &Data,
) -> Result<aws_sdk_s3::operation::put_object::PutObjectOutput, Error> { ) -> Result<aws_sdk_s3::operation::put_object::PutObjectOutput, Box<Error>> {
let client = init_client(&self.config).await; let client = init_client(&self.config).await;
let data_content = if data.raw_data.is_empty() { let data_content = if data.raw_data.is_empty() {
match load_data(&data.filepath).await { match load_data(&data.filepath).await {
Ok(content) => content, Ok(content) => content,
Err(err) => return Err(Error::Info(err.to_string())), Err(err) => return Err(Box::new(Error::Info(err.to_string()))),
} }
} else { } else {
data.raw_data.to_owned() data.raw_data.to_owned()
@@ -74,7 +74,54 @@ impl Labyrinth {
.await .await
{ {
Ok(response) => Ok(response), Ok(response) => Ok(response),
Err(err) => Err(Error::Info(err.to_string())), Err(err) => Err(Box::new(Error::Info(err.to_string()))),
}
}
/// Download object from the bucket
pub async fn download(&self, file_key: &str) -> Result<Vec<u8>, Box<Error>> {
let client = init_client(&self.config).await;
match client
.get_object()
.bucket(self.config.bucket.clone())
.key(file_key)
.send()
.await
{
Ok(response) => {
let body = response.body;
// Get the body as ByteStream
match body.collect().await {
Ok(data) => {
let bytes = data.into_bytes();
let raw_data = bytes.to_vec();
Ok(raw_data)
}
Err(err) => Err(Box::new(Error::Info(err.to_string()))),
}
}
Err(err) => Err(Box::new(Error::Info(err.to_string()))),
}
}
/// Delete an object from the bucket
pub async fn delete(
&self,
file_key: &str,
) -> Result<aws_sdk_s3::operation::delete_object::DeleteObjectOutput, Box<Error>> {
let client = init_client(&self.config).await;
match client
.delete_object()
.bucket(self.config.bucket.clone())
.key(file_key)
.send()
.await
{
Ok(response) => Ok(response),
Err(err) => Err(Box::new(Error::Info(err.to_string()))),
} }
} }
} }