Compare commits

...

13 Commits

Author SHA1 Message Date
f87c049ab3 Bug fix release (#35)
All checks were successful
Rust Build / Check (push) Successful in 34s
Rust Build / Test Suite (push) Successful in 30s
Rust Build / Rustfmt (push) Successful in 30s
Rust Build / Clippy (push) Successful in 33s
Rust Build / build (push) Successful in 29s
Reviewed-on: #35
2025-07-23 22:07:54 +00:00
5baecbaa9a Duration (#40)
Some checks failed
Release Tagging / release (push) Successful in 31s
Rust Build / Check (push) Successful in 29s
Rust Build / Check (pull_request) Successful in 28s
Rust Build / Test Suite (push) Failing after 29s
Rust Build / Rustfmt (push) Successful in 28s
Rust Build / Clippy (push) Successful in 29s
Rust Build / build (push) Successful in 34s
Rust Build / Test Suite (pull_request) Successful in 29s
Rust Build / Clippy (pull_request) Successful in 31s
Rust Build / build (pull_request) Successful in 33s
Rust Build / Rustfmt (pull_request) Successful in 29s
Reviewed-on: #40
Co-authored-by: phoenix <kundeng00@pm.me>
Co-committed-by: phoenix <kundeng00@pm.me>
2025-07-04 21:45:48 +00:00
f4b71de969 Version bump (#39)
All checks were successful
Release Tagging / release (push) Successful in 29s
Rust Build / Check (push) Successful in 25s
Rust Build / Test Suite (push) Successful in 28s
Rust Build / Rustfmt (push) Successful in 27s
Rust Build / Clippy (push) Successful in 28s
Rust Build / build (push) Successful in 30s
Rust Build / Check (pull_request) Successful in 29s
Rust Build / Test Suite (pull_request) Successful in 31s
Rust Build / Rustfmt (pull_request) Successful in 29s
Rust Build / Clippy (pull_request) Successful in 27s
Rust Build / build (pull_request) Successful in 33s
Reviewed-on: #39
Co-authored-by: phoenix <kundeng00@pm.me>
Co-committed-by: phoenix <kundeng00@pm.me>
2025-06-29 19:39:02 +00:00
5288b5de30 Updated lofty and tempfile (#38)
Some checks failed
Rust Build / Check (pull_request) Successful in 27s
Rust Build / Rustfmt (push) Successful in 28s
Rust Build / Clippy (push) Successful in 29s
Rust Build / build (push) Successful in 33s
Rust Build / Test Suite (pull_request) Failing after 32s
Rust Build / Rustfmt (pull_request) Successful in 26s
Rust Build / Check (push) Successful in 27s
Release Tagging / release (push) Successful in 32s
Rust Build / Test Suite (push) Successful in 28s
Rust Build / Clippy (pull_request) Successful in 27s
Rust Build / build (pull_request) Successful in 29s
Reviewed-on: #38
Co-authored-by: phoenix <kundeng00@pm.me>
Co-committed-by: phoenix <kundeng00@pm.me>
2025-06-29 19:30:29 +00:00
f51b3a0c4e Rust std change (#37)
Some checks failed
Rust Build / Test Suite (push) Successful in 26s
Rust Build / Clippy (push) Successful in 26s
Rust Build / build (push) Successful in 31s
Rust Build / Test Suite (pull_request) Failing after 27s
Rust Build / Clippy (pull_request) Successful in 26s
Rust Build / build (pull_request) Successful in 30s
Release Tagging / release (push) Successful in 31s
Rust Build / Check (push) Successful in 26s
Rust Build / Check (pull_request) Successful in 25s
Rust Build / Rustfmt (push) Successful in 26s
Rust Build / Rustfmt (pull_request) Successful in 26s
Reviewed-on: #37
Co-authored-by: phoenix <kundeng00@pm.me>
Co-committed-by: phoenix <kundeng00@pm.me>
2025-06-29 19:24:51 +00:00
565d361b64 Added function to get all Types (#36)
All checks were successful
Release Tagging / release (push) Successful in 33s
Rust Build / Check (push) Successful in 26s
Rust Build / Test Suite (push) Successful in 29s
Rust Build / Rustfmt (push) Successful in 27s
Rust Build / Clippy (push) Successful in 29s
Rust Build / build (push) Successful in 34s
Rust Build / Check (pull_request) Successful in 36s
Rust Build / Test Suite (pull_request) Successful in 41s
Rust Build / Rustfmt (pull_request) Successful in 28s
Rust Build / Clippy (pull_request) Successful in 38s
Rust Build / build (pull_request) Successful in 32s
Reviewed-on: #36
Co-authored-by: phoenix <kundeng00@pm.me>
Co-committed-by: phoenix <kundeng00@pm.me>
2025-06-26 22:23:25 +00:00
973d163ca5 coverart fix (#34)
All checks were successful
Release Tagging / release (push) Successful in 29s
Rust Build / Check (pull_request) Successful in 27s
Rust Build / Rustfmt (push) Successful in 29s
Rust Build / Clippy (push) Successful in 28s
Rust Build / Test Suite (pull_request) Successful in 31s
Rust Build / Rustfmt (pull_request) Successful in 29s
Rust Build / Clippy (pull_request) Successful in 29s
Rust Build / Check (push) Successful in 27s
Rust Build / Test Suite (push) Successful in 29s
Rust Build / build (push) Successful in 35s
Rust Build / build (pull_request) Successful in 33s
Reviewed-on: #34
Co-authored-by: phoenix <kundeng00@pm.me>
Co-committed-by: phoenix <kundeng00@pm.me>
2025-06-25 21:44:04 +00:00
e11ec6ffd0 Bug fix and minor changes release (#28)
All checks were successful
Rust Build / Check (push) Successful in 25s
Rust Build / Test Suite (push) Successful in 27s
Rust Build / Rustfmt (push) Successful in 24s
Rust Build / Clippy (push) Successful in 27s
Rust Build / build (push) Successful in 29s
Rust Build / Check (pull_request) Successful in 28s
Rust Build / Test Suite (pull_request) Successful in 29s
Rust Build / Rustfmt (pull_request) Successful in 28s
Rust Build / Clippy (pull_request) Successful in 27s
Rust Build / build (pull_request) Successful in 31s
Reviewed-on: #28
2025-06-24 23:53:20 +00:00
9c7eefe7af Version bump (#32)
All checks were successful
Rust Build / Check (push) Successful in 25s
Rust Build / Test Suite (push) Successful in 27s
Rust Build / Rustfmt (push) Successful in 25s
Rust Build / Clippy (push) Successful in 26s
Rust Build / build (push) Successful in 32s
Release Tagging / release (push) Successful in 31s
Rust Build / Check (pull_request) Successful in 30s
Rust Build / Test Suite (pull_request) Successful in 29s
Rust Build / Rustfmt (pull_request) Successful in 26s
Rust Build / Clippy (pull_request) Successful in 26s
Rust Build / build (pull_request) Successful in 32s
Reviewed-on: #32
Co-authored-by: phoenix <kundeng00@pm.me>
Co-committed-by: phoenix <kundeng00@pm.me>
2025-06-24 23:46:51 +00:00
cc02111508 Remove dependency (#33)
All checks were successful
Rust Build / build (pull_request) Successful in 29s
Release Tagging / release (push) Successful in 31s
Rust Build / Check (push) Successful in 24s
Rust Build / Check (pull_request) Successful in 25s
Rust Build / Test Suite (push) Successful in 27s
Rust Build / Rustfmt (push) Successful in 26s
Rust Build / Clippy (push) Successful in 27s
Rust Build / build (push) Successful in 30s
Rust Build / Test Suite (pull_request) Successful in 26s
Rust Build / Rustfmt (pull_request) Successful in 25s
Rust Build / Clippy (pull_request) Successful in 27s
Reviewed-on: #33
Co-authored-by: phoenix <kundeng00@pm.me>
Co-committed-by: phoenix <kundeng00@pm.me>
2025-06-24 23:38:43 +00:00
2a798dea9c Next release (#14)
All checks were successful
Release Tagging / release (push) Successful in 36s
Rust Build / Check (push) Successful in 32s
Rust Build / Test Suite (push) Successful in 39s
Rust Build / Rustfmt (push) Successful in 27s
Rust Build / Clippy (push) Successful in 39s
Rust Build / build (push) Successful in 43s
Reviewed-on: #14
2025-04-19 21:27:21 +00:00
5e57b9146c Release (#8)
All checks were successful
Release Tagging / release (push) Successful in 35s
Rust Build / Check (push) Successful in 38s
Rust Build / Test Suite (push) Successful in 34s
Rust Build / Rustfmt (push) Successful in 34s
Rust Build / Clippy (push) Successful in 37s
Rust Build / build (push) Successful in 41s
Reviewed-on: #8
2025-04-12 19:32:16 +00:00
0dc8c153d2 devel (#3)
All checks were successful
Release Tagging / release (push) Successful in 35s
Rust Build / Check (push) Successful in 31s
Rust Build / Test Suite (push) Successful in 28s
Rust Build / Rustfmt (push) Successful in 25s
Rust Build / Clippy (push) Successful in 33s
Rust Build / build (push) Successful in 29s
Reviewed-on: #3
2025-03-30 18:11:03 +00:00
9 changed files with 166 additions and 362 deletions

View File

@@ -17,7 +17,7 @@ jobs:
- name: Install Rust
uses: actions-rs/toolchain@v1
with:
toolchain: 1.86.0
toolchain: 1.88.0
components: cargo
- name: Extract Version from Cargo.toml

View File

@@ -18,7 +18,7 @@ jobs:
- uses: actions/checkout@v4
- uses: actions-rust-lang/setup-rust-toolchain@v1
with:
toolchain: 1.86.0
toolchain: 1.88.0
- run: |
mkdir -p ~/.ssh
echo "${{ secrets.MYREPO_TOKEN }}" > ~/.ssh/gitlab_deploy_key
@@ -36,7 +36,7 @@ jobs:
- uses: actions/checkout@v4
- uses: actions-rust-lang/setup-rust-toolchain@v1
with:
toolchain: 1.86.0
toolchain: 1.88.0
- run: |
mkdir -p ~/.ssh
echo "${{ secrets.MYREPO_TOKEN }}" > ~/.ssh/gitlab_deploy_key
@@ -54,7 +54,7 @@ jobs:
- uses: actions/checkout@v4
- uses: actions-rust-lang/setup-rust-toolchain@v1
with:
toolchain: 1.86.0
toolchain: 1.88.0
- run: rustup component add rustfmt
- run: |
mkdir -p ~/.ssh
@@ -73,7 +73,7 @@ jobs:
- uses: actions/checkout@v4
- uses: actions-rust-lang/setup-rust-toolchain@v1
with:
toolchain: 1.86.0
toolchain: 1.88.0
- run: rustup component add clippy
- run: |
mkdir -p ~/.ssh
@@ -92,7 +92,7 @@ jobs:
- uses: actions/checkout@v4
- uses: actions-rust-lang/setup-rust-toolchain@v1
with:
toolchain: 1.86.0
toolchain: 1.88.0
- run: |
mkdir -p ~/.ssh
echo "${{ secrets.MYREPO_TOKEN }}" > ~/.ssh/gitlab_deploy_key
@@ -100,4 +100,4 @@ jobs:
ssh-keyscan ${{ vars.MYHOST }} >> ~/.ssh/known_hosts
eval $(ssh-agent -s)
ssh-add -v ~/.ssh/gitlab_deploy_key
cargo build --release
cargo build --release

273
Cargo.lock generated
View File

@@ -14,12 +14,6 @@ version = "2.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5c8214115b7bf84099f1309324e63141d4c5d7cc26862f97a0a857dbefe165bd"
[[package]]
name = "bumpalo"
version = "3.18.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "793db76d6187cd04dff33004d8e6c9cc4e05cd330500379d2394209271b4aeee"
[[package]]
name = "byteorder"
version = "1.5.0"
@@ -47,16 +41,6 @@ version = "2.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2a2330da5de22e8a3cb63252ce2abb30116bf5265e89c0e01bc17015ce30a476"
[[package]]
name = "deranged"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9c9e6a11ca8224451684bc0d7d5a7adbf8f2fd6887261a1cfc3c0432f9d4068e"
dependencies = [
"powerfmt",
"serde",
]
[[package]]
name = "errno"
version = "0.3.10"
@@ -97,41 +81,12 @@ dependencies = [
[[package]]
name = "icarus_meta"
version = "0.1.30"
version = "0.3.0"
dependencies = [
"icarus_models",
"lofty",
"tempfile",
]
[[package]]
name = "icarus_models"
version = "0.4.3"
source = "git+ssh://git@git.kundeng.us/phoenix/icarus_models.git?tag=v0.4.3#6aa4c3d74142f5fceb4a6e95078bb3ae0a2d99c5"
dependencies = [
"rand",
"serde",
"serde_json",
"time",
"uuid",
]
[[package]]
name = "itoa"
version = "1.0.15"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4a5f13b858c8d314ee3e8f639011f7ccefe71f97f96e50151fb991f267928e2c"
[[package]]
name = "js-sys"
version = "0.3.77"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1cfaf33c695fc6e08064efbc1f72ec937429614f25eef83af942d0e227c3a28f"
dependencies = [
"once_cell",
"wasm-bindgen",
]
[[package]]
name = "libc"
version = "0.2.171"
@@ -176,12 +131,6 @@ version = "0.4.27"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "13dc2df351e3202783a1fe0d44375f7295ffb4049267b0f3018346dc122a1d94"
[[package]]
name = "memchr"
version = "2.7.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3"
[[package]]
name = "miniz_oxide"
version = "0.8.9"
@@ -191,12 +140,6 @@ dependencies = [
"adler2",
]
[[package]]
name = "num-conv"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "51d515d32fb182ee37cda2ccdcb92950d6a3c2893aa280e540671c2cd0f3b1d9"
[[package]]
name = "ogg_pager"
version = "0.7.0"
@@ -218,21 +161,6 @@ version = "1.0.15"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "57c0d7b74b563b49d38dae00a0c37d4d6de9b432382b2892f0574ddcae73fd0a"
[[package]]
name = "powerfmt"
version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "439ee305def115ba05938db6eb1644ff94165c5ab5e9420d1c1bcedbba909391"
[[package]]
name = "ppv-lite86"
version = "0.2.21"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "85eae3c4ed2f50dcfe72643da4befc30deadb458a9b590d720cde2f2b1e97da9"
dependencies = [
"zerocopy",
]
[[package]]
name = "proc-macro2"
version = "1.0.94"
@@ -257,36 +185,6 @@ version = "5.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "74765f6d916ee2faa39bc8e68e4f3ed8949b48cccdac59983d287a7cb71ce9c5"
[[package]]
name = "rand"
version = "0.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3779b94aeb87e8bd4e834cee3650289ee9e0d5677f976ecdb6d219e5f4f6cd94"
dependencies = [
"rand_chacha",
"rand_core",
"zerocopy",
]
[[package]]
name = "rand_chacha"
version = "0.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d3022b5f1df60f26e1ffddd6c66e8aa15de382ae63b3a0c1bfc0e4d3e3f325cb"
dependencies = [
"ppv-lite86",
"rand_core",
]
[[package]]
name = "rand_core"
version = "0.9.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "99d9a13982dcf210057a8a78572b2217b667c3beacbf3a0d8b454f6f82837d38"
dependencies = [
"getrandom",
]
[[package]]
name = "rustix"
version = "1.0.3"
@@ -300,50 +198,6 @@ dependencies = [
"windows-sys",
]
[[package]]
name = "rustversion"
version = "1.0.21"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8a0d197bd2c9dc6e53b84da9556a69ba4cdfab8619eb41a8bd1cc2027a0f6b1d"
[[package]]
name = "ryu"
version = "1.0.20"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "28d3b2b1366ec20994f1fd18c3c594f05c5dd4bc44d8bb0c1c632c8d6829481f"
[[package]]
name = "serde"
version = "1.0.219"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5f0e2c6ed6606019b4e29e69dbaba95b11854410e5347d525002456dbbb786b6"
dependencies = [
"serde_derive",
]
[[package]]
name = "serde_derive"
version = "1.0.219"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5b0276cf7f2c73365f7157c8123c21cd9a50fbbd844757af28ca1f5925fc2a00"
dependencies = [
"proc-macro2",
"quote",
"syn",
]
[[package]]
name = "serde_json"
version = "1.0.140"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "20068b6e96dc6c9bd23e01df8827e6c7e1f2fddd43c21810382803c136b99373"
dependencies = [
"itoa",
"memchr",
"ryu",
"serde",
]
[[package]]
name = "syn"
version = "2.0.100"
@@ -357,9 +211,9 @@ dependencies = [
[[package]]
name = "tempfile"
version = "3.19.1"
version = "3.20.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7437ac7763b9b123ccf33c338a5cc1bac6f69b45a136c19bdd8a65e3916435bf"
checksum = "e8a64e3985349f2441a1a9ef0b853f869006c3855f2cda6862a94d26ebb9d6a1"
dependencies = [
"fastrand",
"getrandom",
@@ -368,55 +222,12 @@ dependencies = [
"windows-sys",
]
[[package]]
name = "time"
version = "0.3.41"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8a7619e19bc266e0f9c5e6686659d394bc57973859340060a69221e57dbc0c40"
dependencies = [
"deranged",
"itoa",
"num-conv",
"powerfmt",
"serde",
"time-core",
"time-macros",
]
[[package]]
name = "time-core"
version = "0.1.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c9e9a38711f559d9e3ce1cdb06dd7c5b8ea546bc90052da6d06bb76da74bb07c"
[[package]]
name = "time-macros"
version = "0.2.22"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3526739392ec93fd8b359c8e98514cb3e8e021beb4e5f597b00a0221f8ed8a49"
dependencies = [
"num-conv",
"time-core",
]
[[package]]
name = "unicode-ident"
version = "1.0.18"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5a5f39404a5da50712a4c1eecf25e90dd62b613502b7e925fd4e4d19b5c96512"
[[package]]
name = "uuid"
version = "1.17.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3cf4199d1e5d15ddd86a694e4d0dffa9c323ce759fea589f00fef9d81cc1931d"
dependencies = [
"getrandom",
"js-sys",
"serde",
"wasm-bindgen",
]
[[package]]
name = "wasi"
version = "0.14.2+wasi-0.2.4"
@@ -426,64 +237,6 @@ dependencies = [
"wit-bindgen-rt",
]
[[package]]
name = "wasm-bindgen"
version = "0.2.100"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1edc8929d7499fc4e8f0be2262a241556cfc54a0bea223790e71446f2aab1ef5"
dependencies = [
"cfg-if",
"once_cell",
"rustversion",
"wasm-bindgen-macro",
]
[[package]]
name = "wasm-bindgen-backend"
version = "0.2.100"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2f0a0651a5c2bc21487bde11ee802ccaf4c51935d0d3d42a6101f98161700bc6"
dependencies = [
"bumpalo",
"log",
"proc-macro2",
"quote",
"syn",
"wasm-bindgen-shared",
]
[[package]]
name = "wasm-bindgen-macro"
version = "0.2.100"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7fe63fc6d09ed3792bd0897b314f53de8e16568c2b3f7982f468c0bf9bd0b407"
dependencies = [
"quote",
"wasm-bindgen-macro-support",
]
[[package]]
name = "wasm-bindgen-macro-support"
version = "0.2.100"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8ae87ea40c9f689fc23f209965b6fb8a99ad69aeeb0231408be24920604395de"
dependencies = [
"proc-macro2",
"quote",
"syn",
"wasm-bindgen-backend",
"wasm-bindgen-shared",
]
[[package]]
name = "wasm-bindgen-shared"
version = "0.2.100"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1a05d73b933a847d6cccdda8f838a22ff101ad9bf93e33684f39c1f5f0eece3d"
dependencies = [
"unicode-ident",
]
[[package]]
name = "windows-sys"
version = "0.59.0"
@@ -565,23 +318,3 @@ checksum = "6f42320e61fe2cfd34354ecb597f86f413484a798ba44a8ca1165c58d42da6c1"
dependencies = [
"bitflags",
]
[[package]]
name = "zerocopy"
version = "0.8.24"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2586fea28e186957ef732a5f8b3be2da217d65c5969d4b1e17f973ebbe876879"
dependencies = [
"zerocopy-derive",
]
[[package]]
name = "zerocopy-derive"
version = "0.8.24"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a996a8f63c5c4448cd959ac1bab0aaa3306ccfd060472f85943ee0750f0169be"
dependencies = [
"proc-macro2",
"quote",
"syn",
]

View File

@@ -1,12 +1,11 @@
[package]
name = "icarus_meta"
version = "0.1.30"
version = "0.3.0"
edition = "2024"
rust-version = "1.86"
rust-version = "1.88"
[dependencies]
lofty = { version = "0.22.3" }
icarus_models = { git = "ssh://git@git.kundeng.us/phoenix/icarus_models.git", tag = "v0.4.3" }
lofty = { version = "0.22.4" }
[dev-dependencies]
tempfile = { version = "3.19.1" }
tempfile = { version = "3.20.0" }

2
README.md Normal file
View File

@@ -0,0 +1,2 @@
Library to manage metadata of flac files, used in various icarus-related software
projects.

View File

@@ -1,2 +1,66 @@
pub mod meta;
pub mod properties;
pub mod types;
pub mod test_util {
pub mod util {
use std::io::{self, Write};
// Function to save a Vec<u8> to a file
pub fn save_bytes_to_file(bytes: &[u8], file_path: &String) -> io::Result<()> {
let file = std::path::Path::new(file_path);
let mut file = std::fs::File::create(file)?;
match file.write_all(bytes) {
Ok(_res) => Ok(()),
Err(err) => Err(err),
}
}
pub fn get_full_path(
directory: &String,
filename: &String,
) -> Result<String, std::io::Error> {
match path_buf(directory, filename) {
Ok(pf) => Ok(pf.display().to_string()),
Err(err) => Err(err),
}
}
pub fn copy_file(
source_path: &String,
destination_path: &String,
) -> Result<u64, std::io::Error> {
let src_path = std::path::Path::new(source_path);
let dest_path = std::path::Path::new(destination_path);
std::fs::copy(src_path, dest_path)
}
pub fn file_exists(directory: &String, filename: &String) -> Result<bool, std::io::Error> {
match path_buf(directory, filename) {
Ok(pf) => Ok(pf.exists()),
Err(err) => Err(err),
}
}
fn path_buf(
directory: &String,
filename: &String,
) -> Result<std::path::PathBuf, std::io::Error> {
let dir_path = std::path::Path::new(&directory);
Ok(dir_path.join(filename))
}
pub const TESTFILEDIRECTORY: &str = "tests/sample_tracks3";
pub fn get_filename(track: i32) -> String {
const FLAC_EXTENSION: &str = ".flac";
if track < 10 {
format!("track0{track}{FLAC_EXTENSION}")
} else {
format!("track{track}{FLAC_EXTENSION}")
}
}
}
}

View File

@@ -21,7 +21,17 @@ pub mod coverart {
match lofty::picture::PictureInformation::from_picture(&pic) {
Ok(info) => {
flac_file.set_picture(0, pic.clone(), info);
Ok(pic.into_data())
match flac_file.save_to_path(
song_filepath,
lofty::config::WriteOptions::default(),
) {
Ok(_) => Ok(pic.into_data()),
Err(err) => Err(std::io::Error::new(
std::io::ErrorKind::InvalidData,
err.to_string(),
)),
}
}
Err(err) => Err(std::io::Error::new(
std::io::ErrorKind::InvalidData,
@@ -265,83 +275,10 @@ pub mod metadata {
#[cfg(test)]
mod tests {
use util::{file_exists, get_full_path};
use super::*;
mod util {
use std::io::{self, Write};
// Function to save a Vec<u8> to a file
pub fn save_bytes_to_file(bytes: &[u8], file_path: &String) -> io::Result<()> {
let file = std::path::Path::new(file_path);
let mut file = std::fs::File::create(file)?;
match file.write_all(bytes) {
Ok(_res) => Ok(()),
Err(err) => Err(err),
}
}
pub fn get_full_path(
directory: &String,
filename: &String,
) -> Result<String, std::io::Error> {
match path_buf(directory, filename) {
Ok(pf) => Ok(pf.display().to_string()),
Err(err) => Err(err),
}
}
pub fn copy_file(
source_path: &String,
destination_path: &String,
) -> Result<u64, std::io::Error> {
let src_path = std::path::Path::new(source_path);
let dest_path = std::path::Path::new(destination_path);
match std::fs::copy(src_path, dest_path) {
Ok(bytes) => Ok(bytes),
Err(err) => Err(err),
}
}
pub fn file_exists(directory: &String, filename: &String) -> Result<bool, std::io::Error> {
match path_buf(directory, filename) {
Ok(pf) => Ok(pf.exists()),
Err(err) => Err(err),
}
}
fn path_buf(
directory: &String,
filename: &String,
) -> Result<std::path::PathBuf, std::io::Error> {
let dir_path = std::path::Path::new(&directory);
Ok(dir_path.join(filename))
}
pub const TESTFILEDIRECTORY: &str = "tests/sample_tracks3";
pub fn get_filename(track: i32) -> String {
let mut filename = String::from("track");
if track < 10 {
filename += "0";
filename += &track.to_string();
} else {
filename += &track.to_string();
}
filename += ".flac";
filename
}
}
mod get {
use super::metadata::get_meta;
use super::*;
use super::super::metadata::get_meta;
use crate::test_util::util;
use crate::test_util::util::{file_exists, get_full_path};
use crate::types;
#[test]
@@ -595,8 +532,9 @@ mod tests {
}
mod set {
use super::metadata::{get_meta, set_meta};
use super::*;
use super::super::metadata::{get_meta, set_meta};
use crate::test_util::util;
use crate::test_util::util::{file_exists, get_full_path};
use crate::types;
#[test]
@@ -1132,7 +1070,9 @@ mod tests {
mod pictures {
use super::*;
use super::super::*;
use crate::test_util::util;
use crate::test_util::util::{file_exists, get_full_path};
#[test]
fn test_get_picture() {

51
src/properties.rs Normal file
View File

@@ -0,0 +1,51 @@
use lofty::file::AudioFile;
pub fn get_duration(song_path: &String) -> Result<std::time::Duration, std::io::Error> {
match std::fs::File::open(song_path) {
Ok(mut content) => {
match lofty::flac::FlacFile::read_from(&mut content, lofty::config::ParseOptions::new())
{
Ok(flac_file) => {
let properties = flac_file.properties();
Ok(properties.duration())
}
Err(err) => Err(std::io::Error::other(err.to_string())),
}
}
Err(err) => Err(err),
}
}
#[cfg(test)]
mod tests {
use crate::test_util;
#[test]
fn test_get_duration() {
let filename = test_util::util::get_filename(1);
let dir = String::from(test_util::util::TESTFILEDIRECTORY);
match test_util::util::file_exists(&dir, &filename) {
Ok(_) => {
let filepath = test_util::util::get_full_path(&dir, &filename).unwrap();
match super::get_duration(&filepath) {
Ok(duration) => {
let song_duration: u64 = 41;
let fetched_song_duration = duration.as_secs();
assert_eq!(
song_duration, fetched_song_duration,
"Durations should match, but they don't {song_duration} {fetched_song_duration} ({duration:?})"
);
}
Err(err) => {
assert!(false, "Error: {err:?}");
}
}
}
Err(err) => {
assert!(false, "Error: {err:?}");
}
}
}
}

View File

@@ -32,6 +32,21 @@ impl MetadataType {
}
}
pub fn all_metadata_types() -> Vec<Type> {
vec![
Type::Album,
Type::Artist,
Type::AlbumArtist,
Type::Date,
Type::Disc,
Type::Genre,
Type::Title,
Type::Track,
Type::TrackCount,
Type::DiscCount,
]
}
pub mod access {
pub fn get_type(t: super::Type) -> Result<String, std::io::Error> {
match t {