Compare commits

..
Author SHA1 Message Date
phoenix 7db41e190e Adding license
labyrinth release Tagging / release (pull_request) Successful in 3m4s
simodels Build / Check (pull_request) Successful in 3m27s
simodels Build / Test Suite (pull_request) Successful in 3m32s
simodels Build / Rustfmt (pull_request) Successful in 4m42s
simodels Build / Clippy (pull_request) Failing after 4m52s
simodels Build / build (pull_request) Successful in 5m8s
2026-08-10 16:51:59 -04:00
phoenix 966aad363b ci: Adding workflow 2026-08-10 16:51:52 -04:00
5 changed files with 383 additions and 440 deletions

No files matched your search

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