From 966aad363b28be55e72c09156b5981ce523c4bda Mon Sep 17 00:00:00 2001 From: phoenix Date: Mon, 10 Aug 2026 16:51:52 -0400 Subject: [PATCH 1/5] ci: Adding workflow --- .gitea/workflows/ci.yml | 73 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 73 insertions(+) diff --git a/.gitea/workflows/ci.yml b/.gitea/workflows/ci.yml index e69de29..9b2ba0f 100644 --- a/.gitea/workflows/ci.yml +++ b/.gitea/workflows/ci.yml @@ -0,0 +1,73 @@ +name: simodels Build + +on: + push: + branches: + - main + pull_request: + branches: + - main + + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + check: + name: Check + runs-on: ubuntu-24.04 + steps: + - uses: actions/checkout@v6 + - uses: actions-rust-lang/setup-rust-toolchain@v1 + with: + toolchain: 1.97 + - uses: Swatinem/rust-cache@v2 + - run: cargo check + + test: + name: Test Suite + runs-on: ubuntu-24.04 + steps: + - uses: actions/checkout@v6 + - uses: actions-rust-lang/setup-rust-toolchain@v1 + with: + toolchain: 1.97 + - uses: Swatinem/rust-cache@v2 + - run: cargo test + + fmt: + name: Rustfmt + runs-on: ubuntu-24.04 + steps: + - uses: actions/checkout@v6 + - uses: actions-rust-lang/setup-rust-toolchain@v1 + with: + toolchain: 1.97 + - uses: Swatinem/rust-cache@v2 + - run: rustup component add rustfmt + - run: cargo fmt --all -- --check + + clippy: + name: Clippy + runs-on: ubuntu-24.04 + steps: + - uses: actions/checkout@v6 + - uses: actions-rust-lang/setup-rust-toolchain@v1 + with: + toolchain: 1.97 + - uses: Swatinem/rust-cache@v2 + - run: rustup component add clippy + - run: cargo clippy -- -D warnings + + build: + name: build + runs-on: ubuntu-24.04 + steps: + - uses: actions/checkout@v6 + - uses: actions-rust-lang/setup-rust-toolchain@v1 + with: + toolchain: 1.97 + - uses: Swatinem/rust-cache@v2 + - run: cargo build + -- 2.47.3 From 7db41e190e21a6837b065f799d29b6898ae986be Mon Sep 17 00:00:00 2001 From: phoenix Date: Mon, 10 Aug 2026 16:51:59 -0400 Subject: [PATCH 2/5] Adding license --- LICENSE | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 LICENSE diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..f5a66d1 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2025 Kun Deng + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. -- 2.47.3 From 8464401337a62719e2273e9b6ec99c62e2b7cf4a Mon Sep 17 00:00:00 2001 From: phoenix Date: Mon, 10 Aug 2026 17:14:48 -0400 Subject: [PATCH 3/5] Adding code to download from the bucket --- src/lib.rs | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/src/lib.rs b/src/lib.rs index 11270d3..73ecb69 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -77,4 +77,31 @@ impl Labyrinth { Err(err) => Err(Error::Info(err.to_string())), } } + + pub async fn download(&self, file_key: &str) -> Result, 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(Error::Info(err.to_string())), + } + } + Err(err) => Err(Error::Info(err.to_string())), + } + } } -- 2.47.3 From 2b6127f6a66c705ac9e0502cde09f17b443f3049 Mon Sep 17 00:00:00 2001 From: phoenix Date: Mon, 10 Aug 2026 17:16:18 -0400 Subject: [PATCH 4/5] Code formatting --- src/lib.rs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 73ecb69..d308129 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -37,8 +37,7 @@ pub async fn init_client(config: &config::Config) -> aws_sdk_s3::Client { .force_path_style(true) .build(); - let client = aws_sdk_s3::Client::from_conf(s3_config); - client + aws_sdk_s3::Client::from_conf(s3_config) } #[derive(Debug)] @@ -83,7 +82,7 @@ impl Labyrinth { match client .get_object() - .bucket(&self.config.bucket.clone()) + .bucket(self.config.bucket.clone()) .key(file_key) .send() .await -- 2.47.3 From 03adc220852acbeae0ab9c7bc253c11016f01a75 Mon Sep 17 00:00:00 2001 From: phoenix Date: Mon, 10 Aug 2026 17:38:05 -0400 Subject: [PATCH 5/5] bump: labyrinth --- Cargo.lock | 2 +- Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 16c1c34..0bac2f4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1370,7 +1370,7 @@ dependencies = [ [[package]] name = "labyrinth" -version = "0.0.2" +version = "0.0.3" dependencies = [ "aws-config", "aws-sdk-s3", diff --git a/Cargo.toml b/Cargo.toml index 4c34a54..c9690f6 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "labyrinth" -version = "0.0.2" +version = "0.0.3" edition = "2024" license = "MIT" description = "Library for managing soaricarus storage" -- 2.47.3