Compare commits
36 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 946c46a23b | |||
| 23db8b9757 | |||
| 80a14e56ad | |||
| b73ffce048 | |||
| f5e6ac567e | |||
| c0607597f1 | |||
| 71374eb731 | |||
| 5101f36aed | |||
| f372d05915 | |||
| bb0524ea62 | |||
| f87c049ab3 | |||
| 5baecbaa9a | |||
| f4b71de969 | |||
| 5288b5de30 | |||
| f51b3a0c4e | |||
| 565d361b64 | |||
| 973d163ca5 | |||
| e11ec6ffd0 | |||
| 9c7eefe7af | |||
| cc02111508 | |||
| f1c1fadd19 | |||
| 68e6c4e025 | |||
| 8f55b28fbe | |||
| 859003fc65 | |||
| 2a798dea9c | |||
| 000639b0f8 | |||
| 2932cdbe1c | |||
| f534687292 | |||
| c80bc7d7e1 | |||
| 805dfb269b | |||
| 43774fe580 | |||
| e0e9eab98c | |||
| 7c1881d102 | |||
| a69212adb0 | |||
| 5e57b9146c | |||
| 0dc8c153d2 |
@@ -4,21 +4,24 @@ on:
|
|||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
- main
|
- main
|
||||||
- devel
|
pull_request:
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
release:
|
release:
|
||||||
runs-on: ubuntu-24.04
|
runs-on: ubuntu-24.04
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout code
|
- name: Checkout code
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v6
|
||||||
with:
|
with:
|
||||||
fetch-depth: 0 # Important for git describe --tags
|
fetch-depth: 0 # Important for git describe --tags
|
||||||
|
|
||||||
- name: Install Rust
|
- name: Install Rust
|
||||||
uses: actions-rs/toolchain@v1
|
uses: actions-rust-lang/setup-rust-toolchain@v1
|
||||||
|
- uses: Swatinem/rust-cache@v2
|
||||||
with:
|
with:
|
||||||
toolchain: 1.86.0
|
toolchain: 1.96.1
|
||||||
components: cargo
|
components: cargo
|
||||||
|
|
||||||
- name: Extract Version from Cargo.toml
|
- name: Extract Version from Cargo.toml
|
||||||
@@ -29,6 +32,7 @@ jobs:
|
|||||||
BRANCH_REF="${GITHUB_REF}"
|
BRANCH_REF="${GITHUB_REF}"
|
||||||
BRANCH_NAME=$(echo "$BRANCH_REF" | cut -d '/' -f 3)
|
BRANCH_NAME=$(echo "$BRANCH_REF" | cut -d '/' -f 3)
|
||||||
PROJECT_TAG_RELEASE="v$VERSION-$BRANCH_NAME-$PROJECT_COMMIT_HASH"
|
PROJECT_TAG_RELEASE="v$VERSION-$BRANCH_NAME-$PROJECT_COMMIT_HASH"
|
||||||
|
|
||||||
echo "::set-output name=project_tag_release::$PROJECT_TAG_RELEASE-680"
|
echo "::set-output name=project_tag_release::$PROJECT_TAG_RELEASE-680"
|
||||||
echo "Version: $VERSION"
|
echo "Version: $VERSION"
|
||||||
echo "Hash: $PROJECT_COMMIT_HASH"
|
echo "Hash: $PROJECT_COMMIT_HASH"
|
||||||
@@ -50,6 +54,3 @@ jobs:
|
|||||||
release_name: Release ${{ steps.version.outputs.project_tag_release }}
|
release_name: Release ${{ steps.version.outputs.project_tag_release }}
|
||||||
body: |
|
body: |
|
||||||
Release of version ${{ steps.version.outputs.project_tag_release }}
|
Release of version ${{ steps.version.outputs.project_tag_release }}
|
||||||
# draft: false
|
|
||||||
# prerelease: ${{ startsWith(github.ref, 'v') == false }} # prerelease if not a valid release tag
|
|
||||||
|
|
||||||
|
|||||||
@@ -4,21 +4,20 @@ on:
|
|||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
- main
|
- main
|
||||||
- devel
|
|
||||||
pull_request:
|
pull_request:
|
||||||
branches:
|
branches:
|
||||||
- main
|
- main
|
||||||
- devel
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
check:
|
check:
|
||||||
name: Check
|
name: Check
|
||||||
runs-on: ubuntu-24.04
|
runs-on: ubuntu-24.04
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v6
|
||||||
- uses: actions-rust-lang/setup-rust-toolchain@v1
|
- uses: actions-rust-lang/setup-rust-toolchain@v1
|
||||||
with:
|
with:
|
||||||
toolchain: 1.86.0
|
toolchain: 1.96.1
|
||||||
|
- uses: Swatinem/rust-cache@v2
|
||||||
- run: |
|
- run: |
|
||||||
mkdir -p ~/.ssh
|
mkdir -p ~/.ssh
|
||||||
echo "${{ secrets.MYREPO_TOKEN }}" > ~/.ssh/gitlab_deploy_key
|
echo "${{ secrets.MYREPO_TOKEN }}" > ~/.ssh/gitlab_deploy_key
|
||||||
@@ -33,10 +32,11 @@ jobs:
|
|||||||
runs-on: ubuntu-24.04
|
runs-on: ubuntu-24.04
|
||||||
needs: setup_ssh
|
needs: setup_ssh
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v6
|
||||||
- uses: actions-rust-lang/setup-rust-toolchain@v1
|
- uses: actions-rust-lang/setup-rust-toolchain@v1
|
||||||
with:
|
with:
|
||||||
toolchain: 1.86.0
|
toolchain: 1.96.1
|
||||||
|
- uses: Swatinem/rust-cache@v2
|
||||||
- run: |
|
- run: |
|
||||||
mkdir -p ~/.ssh
|
mkdir -p ~/.ssh
|
||||||
echo "${{ secrets.MYREPO_TOKEN }}" > ~/.ssh/gitlab_deploy_key
|
echo "${{ secrets.MYREPO_TOKEN }}" > ~/.ssh/gitlab_deploy_key
|
||||||
@@ -51,11 +51,12 @@ jobs:
|
|||||||
runs-on: ubuntu-24.04
|
runs-on: ubuntu-24.04
|
||||||
needs: setup_ssh
|
needs: setup_ssh
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v6
|
||||||
- uses: actions-rust-lang/setup-rust-toolchain@v1
|
- uses: actions-rust-lang/setup-rust-toolchain@v1
|
||||||
with:
|
with:
|
||||||
toolchain: 1.86.0
|
toolchain: 1.96.1
|
||||||
- run: rustup component add rustfmt
|
- run: rustup component add rustfmt
|
||||||
|
- uses: Swatinem/rust-cache@v2
|
||||||
- run: |
|
- run: |
|
||||||
mkdir -p ~/.ssh
|
mkdir -p ~/.ssh
|
||||||
echo "${{ secrets.MYREPO_TOKEN }}" > ~/.ssh/gitlab_deploy_key
|
echo "${{ secrets.MYREPO_TOKEN }}" > ~/.ssh/gitlab_deploy_key
|
||||||
@@ -70,10 +71,11 @@ jobs:
|
|||||||
runs-on: ubuntu-24.04
|
runs-on: ubuntu-24.04
|
||||||
needs: setup_ssh
|
needs: setup_ssh
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v6
|
||||||
- uses: actions-rust-lang/setup-rust-toolchain@v1
|
- uses: actions-rust-lang/setup-rust-toolchain@v1
|
||||||
with:
|
with:
|
||||||
toolchain: 1.86.0
|
toolchain: 1.96.1
|
||||||
|
- uses: Swatinem/rust-cache@v2
|
||||||
- run: rustup component add clippy
|
- run: rustup component add clippy
|
||||||
- run: |
|
- run: |
|
||||||
mkdir -p ~/.ssh
|
mkdir -p ~/.ssh
|
||||||
@@ -89,10 +91,11 @@ jobs:
|
|||||||
runs-on: ubuntu-24.04
|
runs-on: ubuntu-24.04
|
||||||
needs: setup_ssh
|
needs: setup_ssh
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v6
|
||||||
- uses: actions-rust-lang/setup-rust-toolchain@v1
|
- uses: actions-rust-lang/setup-rust-toolchain@v1
|
||||||
with:
|
with:
|
||||||
toolchain: 1.86.0
|
toolchain: 1.96.1
|
||||||
|
- uses: Swatinem/rust-cache@v2
|
||||||
- run: |
|
- run: |
|
||||||
mkdir -p ~/.ssh
|
mkdir -p ~/.ssh
|
||||||
echo "${{ secrets.MYREPO_TOKEN }}" > ~/.ssh/gitlab_deploy_key
|
echo "${{ secrets.MYREPO_TOKEN }}" > ~/.ssh/gitlab_deploy_key
|
||||||
@@ -100,4 +103,4 @@ jobs:
|
|||||||
ssh-keyscan ${{ vars.MYHOST }} >> ~/.ssh/known_hosts
|
ssh-keyscan ${{ vars.MYHOST }} >> ~/.ssh/known_hosts
|
||||||
eval $(ssh-agent -s)
|
eval $(ssh-agent -s)
|
||||||
ssh-add -v ~/.ssh/gitlab_deploy_key
|
ssh-add -v ~/.ssh/gitlab_deploy_key
|
||||||
cargo build --release
|
cargo build --release
|
||||||
|
|||||||
@@ -1,2 +1 @@
|
|||||||
/target
|
/target
|
||||||
Cargo.lock
|
|
||||||
|
|||||||
Generated
+437
@@ -0,0 +1,437 @@
|
|||||||
|
# This file is automatically @generated by Cargo.
|
||||||
|
# It is not intended for manual editing.
|
||||||
|
version = 4
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "adler2"
|
||||||
|
version = "2.0.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "320119579fcad9c21884f5c4861d16174d0e06250625266f50fe6898340abefa"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "bitflags"
|
||||||
|
version = "2.13.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "b4388bee8683e3d04af747c73422af53102d2bd24d9eadb6cbc100baef4b43f8"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "bumpalo"
|
||||||
|
version = "3.20.3"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "72f5acc6cb2ba439de613abc23857ec3d78374d8ed5ac84e9d11336e87da8649"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "byteorder"
|
||||||
|
version = "1.5.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "cfb"
|
||||||
|
version = "0.7.3"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "d38f2da7a0a2c4ccf0065be06397cc26a81f4e528be095826eee9d4adbb8c60f"
|
||||||
|
dependencies = [
|
||||||
|
"byteorder",
|
||||||
|
"fnv",
|
||||||
|
"uuid",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "cfg-if"
|
||||||
|
version = "1.0.4"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "9330f8b2ff13f34540b44e946ef35111825727b38d33286ef986142615121801"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "chacha20"
|
||||||
|
version = "0.10.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "d524456ba66e72eb8b115ff89e01e497f8e6d11d78b70b1aa13c0fbd97540a81"
|
||||||
|
dependencies = [
|
||||||
|
"cfg-if",
|
||||||
|
"cpufeatures",
|
||||||
|
"rand_core",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "cpufeatures"
|
||||||
|
version = "0.3.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "8b2a41393f66f16b0823bb79094d54ac5fbd34ab292ddafb9a0456ac9f87d201"
|
||||||
|
dependencies = [
|
||||||
|
"libc",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "crc32fast"
|
||||||
|
version = "1.5.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "9481c1c90cbf2ac953f07c8d4a58aa3945c425b7185c9154d67a65e4230da511"
|
||||||
|
dependencies = [
|
||||||
|
"cfg-if",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "data-encoding"
|
||||||
|
version = "2.11.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "a4ae5f15dda3c708c0ade84bfee31ccab44a3da4f88015ed22f63732abe300c8"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "errno"
|
||||||
|
version = "0.3.14"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "39cab71617ae0d63f51a36d69f866391735b51691dbda63cf6f96d042b63efeb"
|
||||||
|
dependencies = [
|
||||||
|
"libc",
|
||||||
|
"windows-sys",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "fastrand"
|
||||||
|
version = "2.4.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "9f1f227452a390804cdb637b74a86990f2a7d7ba4b7d5693aac9b4dd6defd8d6"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "flate2"
|
||||||
|
version = "1.1.9"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "843fba2746e448b37e26a819579957415c8cef339bf08564fe8b7ddbd959573c"
|
||||||
|
dependencies = [
|
||||||
|
"crc32fast",
|
||||||
|
"miniz_oxide",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "fnv"
|
||||||
|
version = "1.0.7"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "futures-core"
|
||||||
|
version = "0.3.32"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "7e3450815272ef58cec6d564423f6e755e25379b217b0bc688e295ba24df6b1d"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "futures-task"
|
||||||
|
version = "0.3.32"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "037711b3d59c33004d3856fbdc83b99d4ff37a24768fa1be9ce3538a1cde4393"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "futures-util"
|
||||||
|
version = "0.3.32"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "389ca41296e6190b48053de0321d02a77f32f8a5d2461dd38762c0593805c6d6"
|
||||||
|
dependencies = [
|
||||||
|
"futures-core",
|
||||||
|
"futures-task",
|
||||||
|
"pin-project-lite",
|
||||||
|
"slab",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "getrandom"
|
||||||
|
version = "0.4.3"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "300e883d756b2e4ec94e02791f39b04b522276138852cfc41d9fb7e904106099"
|
||||||
|
dependencies = [
|
||||||
|
"cfg-if",
|
||||||
|
"libc",
|
||||||
|
"r-efi",
|
||||||
|
"rand_core",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "icarus_meta"
|
||||||
|
version = "0.6.1"
|
||||||
|
dependencies = [
|
||||||
|
"imghdr",
|
||||||
|
"infer",
|
||||||
|
"lofty",
|
||||||
|
"rand",
|
||||||
|
"tempfile",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "imghdr"
|
||||||
|
version = "0.7.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "c8b35f3ad95576ac81603375dfe47a0450b70a368aa34d2b6e5bb0a0d7f02428"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "infer"
|
||||||
|
version = "0.19.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "a588916bfdfd92e71cacef98a63d9b1f0d74d6599980d11894290e7ddefffcf7"
|
||||||
|
dependencies = [
|
||||||
|
"cfb",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "js-sys"
|
||||||
|
version = "0.3.103"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "53b44bfcdb3f8d5837a46dae1ca9660a837176eee74a28b229bc626816589102"
|
||||||
|
dependencies = [
|
||||||
|
"cfg-if",
|
||||||
|
"futures-util",
|
||||||
|
"wasm-bindgen",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "libc"
|
||||||
|
version = "0.2.186"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "68ab91017fe16c622486840e4c83c9a37afeff978bd239b5293d61ece587de66"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "linux-raw-sys"
|
||||||
|
version = "0.12.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "32a66949e030da00e8c7d4434b251670a91556f4144941d37452769c25d58a53"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "lofty"
|
||||||
|
version = "0.24.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "dec4feeff6c7d75093278133a06e827d7af6d2bfe20b0f331f9d10338a5ec7ca"
|
||||||
|
dependencies = [
|
||||||
|
"byteorder",
|
||||||
|
"data-encoding",
|
||||||
|
"flate2",
|
||||||
|
"lofty_attr",
|
||||||
|
"log",
|
||||||
|
"ogg_pager",
|
||||||
|
"paste",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "lofty_attr"
|
||||||
|
version = "0.12.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "458ace39169e4b83c4f77ae3d42d5d1d11c422feef590219a97c973d3b524557"
|
||||||
|
dependencies = [
|
||||||
|
"proc-macro2",
|
||||||
|
"quote",
|
||||||
|
"syn",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "log"
|
||||||
|
version = "0.4.33"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "0ceec5bc11778974d1bcb055b18002eba7f4b3518b6a0081b3af5f21666da9ad"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "miniz_oxide"
|
||||||
|
version = "0.8.9"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "1fa76a2c86f704bdb222d66965fb3d63269ce38518b83cb0575fca855ebb6316"
|
||||||
|
dependencies = [
|
||||||
|
"adler2",
|
||||||
|
"simd-adler32",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "ogg_pager"
|
||||||
|
version = "0.7.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "9d36b1d6964c3ac92b7aea701057e02b6b91143d70d83b20abf75a231a3c0216"
|
||||||
|
dependencies = [
|
||||||
|
"byteorder",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "once_cell"
|
||||||
|
version = "1.21.4"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "9f7c3e4beb33f85d45ae3e3a1792185706c8e16d043238c593331cc7cd313b50"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "paste"
|
||||||
|
version = "1.0.15"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "57c0d7b74b563b49d38dae00a0c37d4d6de9b432382b2892f0574ddcae73fd0a"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "pin-project-lite"
|
||||||
|
version = "0.2.17"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "a89322df9ebe1c1578d689c92318e070967d1042b512afbe49518723f4e6d5cd"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "proc-macro2"
|
||||||
|
version = "1.0.106"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "8fd00f0bb2e90d81d1044c2b32617f68fcb9fa3bb7640c23e9c748e53fb30934"
|
||||||
|
dependencies = [
|
||||||
|
"unicode-ident",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "quote"
|
||||||
|
version = "1.0.46"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "dfbc457d0c7a0759a614551b11a6409e5951f6c7537be1f1b7682b9ae9230368"
|
||||||
|
dependencies = [
|
||||||
|
"proc-macro2",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "r-efi"
|
||||||
|
version = "6.0.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "f8dcc9c7d52a811697d2151c701e0d08956f92b0e24136cf4cf27b57a6a0d9bf"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "rand"
|
||||||
|
version = "0.10.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "c7f5fa3a058cd35567ef9bfa5e75732bee0f9e4c55fa90477bef2dfcdbc4be80"
|
||||||
|
dependencies = [
|
||||||
|
"chacha20",
|
||||||
|
"getrandom",
|
||||||
|
"rand_core",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "rand_core"
|
||||||
|
version = "0.10.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "63b8176103e19a2643978565ca18b50549f6101881c443590420e4dc998a3c69"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "rustix"
|
||||||
|
version = "1.1.4"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "b6fe4565b9518b83ef4f91bb47ce29620ca828bd32cb7e408f0062e9930ba190"
|
||||||
|
dependencies = [
|
||||||
|
"bitflags",
|
||||||
|
"errno",
|
||||||
|
"libc",
|
||||||
|
"linux-raw-sys",
|
||||||
|
"windows-sys",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "rustversion"
|
||||||
|
version = "1.0.23"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "cf54715a573b99ac80df0bc206da022bcd442c974952c7b9720069370852e21f"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "simd-adler32"
|
||||||
|
version = "0.3.9"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "703d5c7ef118737c72f1af64ad2f6f8c5e1921f818cdcb97b8fe6fc69bf66214"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "slab"
|
||||||
|
version = "0.4.12"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "0c790de23124f9ab44544d7ac05d60440adc586479ce501c1d6d7da3cd8c9cf5"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "syn"
|
||||||
|
version = "2.0.118"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "1b9ae57f904213ebb649ce6895b8a66c66f0203b9319718f69a5612a065b1422"
|
||||||
|
dependencies = [
|
||||||
|
"proc-macro2",
|
||||||
|
"quote",
|
||||||
|
"unicode-ident",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "tempfile"
|
||||||
|
version = "3.27.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "32497e9a4c7b38532efcdebeef879707aa9f794296a4f0244f6f69e9bc8574bd"
|
||||||
|
dependencies = [
|
||||||
|
"fastrand",
|
||||||
|
"getrandom",
|
||||||
|
"once_cell",
|
||||||
|
"rustix",
|
||||||
|
"windows-sys",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "unicode-ident"
|
||||||
|
version = "1.0.24"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "e6e4313cd5fcd3dad5cafa179702e2b244f760991f45397d14d4ebf38247da75"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "uuid"
|
||||||
|
version = "1.23.4"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "bf80a72845275afea99e7f2b434723d3bc7e38470fcd1c7ed39a599c73319a53"
|
||||||
|
dependencies = [
|
||||||
|
"js-sys",
|
||||||
|
"wasm-bindgen",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "wasm-bindgen"
|
||||||
|
version = "0.2.126"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "4b067c0c11094aef6b7a801c1e34a26affafdf3d051dba08456b868789aaf9a4"
|
||||||
|
dependencies = [
|
||||||
|
"cfg-if",
|
||||||
|
"once_cell",
|
||||||
|
"rustversion",
|
||||||
|
"wasm-bindgen-macro",
|
||||||
|
"wasm-bindgen-shared",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "wasm-bindgen-macro"
|
||||||
|
version = "0.2.126"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "167ce5e579f6bcf889c4f7175a8a5a585de84e8ff93976ce393efa5f2837aab1"
|
||||||
|
dependencies = [
|
||||||
|
"quote",
|
||||||
|
"wasm-bindgen-macro-support",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "wasm-bindgen-macro-support"
|
||||||
|
version = "0.2.126"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "f3997c7839262f4ef12cf90b818d6340c18e80f263f1a94bf157d0ec4420380e"
|
||||||
|
dependencies = [
|
||||||
|
"bumpalo",
|
||||||
|
"proc-macro2",
|
||||||
|
"quote",
|
||||||
|
"syn",
|
||||||
|
"wasm-bindgen-shared",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "wasm-bindgen-shared"
|
||||||
|
version = "0.2.126"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "dc1b4cb0cc549fcf58d7dfc081778139b3d283a081644e833e84682ad71cea24"
|
||||||
|
dependencies = [
|
||||||
|
"unicode-ident",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "windows-link"
|
||||||
|
version = "0.2.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "f0805222e57f7521d6a62e36fa9163bc891acd422f971defe97d64e70d0a4fe5"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "windows-sys"
|
||||||
|
version = "0.61.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "ae137229bcbd6cdf0f7b80a31df61766145077ddf49416a728b02cb3921ff3fc"
|
||||||
|
dependencies = [
|
||||||
|
"windows-link",
|
||||||
|
]
|
||||||
+9
-4
@@ -1,9 +1,14 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "icarus_meta"
|
name = "icarus_meta"
|
||||||
version = "0.1.0"
|
version = "0.6.1"
|
||||||
edition = "2024"
|
edition = "2024"
|
||||||
rust-version = "1.86"
|
rust-version = "1.95"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
lofty = { version = "0.22.3" }
|
lofty = { version = "0.24.0" }
|
||||||
icarus_models = { git = "ssh://git@git.kundeng.us/phoenix/icarus_models.git", tag = "v0.4.3" }
|
imghdr = { version = "0.7.0" }
|
||||||
|
infer = { version = "0.19.0" }
|
||||||
|
rand = { version = "0.10.2" }
|
||||||
|
|
||||||
|
[dev-dependencies]
|
||||||
|
tempfile = { version = "3.27.0" }
|
||||||
|
|||||||
@@ -0,0 +1,2 @@
|
|||||||
|
Library to manage metadata of flac files, used in various icarus-related software
|
||||||
|
projects.
|
||||||
@@ -0,0 +1,89 @@
|
|||||||
|
/// Gets the file type of a CoverArt given it's path
|
||||||
|
pub fn file_type_from_filepath(
|
||||||
|
filepath: &str,
|
||||||
|
) -> Result<crate::detection::FileType, std::io::Error> {
|
||||||
|
match imghdr::from_file(filepath) {
|
||||||
|
Ok(Some(imghdr::Type::Jpeg)) => Ok(crate::detection::FileType {
|
||||||
|
mime: String::from(constants::mime::JPEG),
|
||||||
|
file_type: String::from(constants::JPEG_TYPE),
|
||||||
|
}),
|
||||||
|
Ok(Some(imghdr::Type::Png)) => Ok(crate::detection::FileType {
|
||||||
|
mime: String::from(constants::mime::PNG),
|
||||||
|
file_type: String::from(constants::PNG_TYPE),
|
||||||
|
}),
|
||||||
|
Ok(None) => Err(std::io::Error::other("Image file not supported")),
|
||||||
|
Err(err) => Err(err),
|
||||||
|
_ => Err(std::io::Error::other("Image file not supported")),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Gets the file type of a CoverArt given it's data
|
||||||
|
pub fn file_type_from_data(data: &Vec<u8>) -> Result<crate::detection::FileType, std::io::Error> {
|
||||||
|
match imghdr::from_bytes(data) {
|
||||||
|
Some(imghdr::Type::Jpeg) => Ok(crate::detection::FileType {
|
||||||
|
mime: String::from(constants::mime::JPEG),
|
||||||
|
file_type: String::from(constants::JPEG_TYPE),
|
||||||
|
}),
|
||||||
|
Some(imghdr::Type::Png) => Ok(crate::detection::FileType {
|
||||||
|
mime: String::from(constants::mime::PNG),
|
||||||
|
file_type: String::from(constants::PNG_TYPE),
|
||||||
|
}),
|
||||||
|
None => Err(std::io::Error::other("Image file not supported")),
|
||||||
|
_ => Err(std::io::Error::other("Image file not supported")),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub mod constants {
|
||||||
|
pub const PNG_TYPE: &str = "png";
|
||||||
|
pub const JPEG_TYPE: &str = "jpeg";
|
||||||
|
pub const JPG_TYPE: &str = "jpg";
|
||||||
|
|
||||||
|
pub mod mime {
|
||||||
|
pub const JPEG: &str = "image/jpeg";
|
||||||
|
pub const PNG: &str = "image/png";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod tests {
|
||||||
|
#[test]
|
||||||
|
fn test_coverart_file_type() {
|
||||||
|
let directory = String::from(crate::test_util::util::TESTFILEDIRECTORY);
|
||||||
|
let filename = String::from("Sample Tracks 3.png");
|
||||||
|
let filepath = format!("{directory}/{filename}");
|
||||||
|
|
||||||
|
match super::file_type_from_filepath(&filepath) {
|
||||||
|
Ok(filetype) => {
|
||||||
|
assert_eq!(
|
||||||
|
filetype.file_type,
|
||||||
|
super::constants::PNG_TYPE,
|
||||||
|
"The file type of the CoverArt should have been png"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
Err(err) => {
|
||||||
|
assert!(false, "Error: {err:?}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_coverart_file_type_from_data() {
|
||||||
|
let directory = String::from(crate::test_util::util::TESTFILEDIRECTORY);
|
||||||
|
let filename = String::from("Sample Tracks 3.png");
|
||||||
|
let filepath = format!("{directory}/{filename}");
|
||||||
|
let data = crate::test_util::util::get_data_from_file(&filepath).unwrap();
|
||||||
|
|
||||||
|
match super::file_type_from_data(&data) {
|
||||||
|
Ok(filetype) => {
|
||||||
|
assert_eq!(
|
||||||
|
filetype.file_type,
|
||||||
|
super::constants::PNG_TYPE,
|
||||||
|
"The file type of the CoverArt should have been png"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
Err(err) => {
|
||||||
|
assert!(false, "Error: {err:?}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,34 @@
|
|||||||
|
pub mod coverart;
|
||||||
|
pub mod song;
|
||||||
|
|
||||||
|
#[derive(Debug, Default)]
|
||||||
|
pub struct FileType {
|
||||||
|
pub mime: String,
|
||||||
|
pub file_type: String,
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Initializes a FileType given a filetype passed.
|
||||||
|
pub fn init_filetype(filetype: &str) -> Result<FileType, std::io::Error> {
|
||||||
|
if filetype == song::constants::FLAC_TYPE {
|
||||||
|
Ok(FileType {
|
||||||
|
mime: String::from(song::constants::mime::FLAC),
|
||||||
|
file_type: String::from(song::constants::FLAC_TYPE),
|
||||||
|
})
|
||||||
|
} else if filetype == coverart::constants::PNG_TYPE {
|
||||||
|
Ok(FileType {
|
||||||
|
mime: String::from(coverart::constants::mime::PNG),
|
||||||
|
file_type: String::from(coverart::constants::PNG_TYPE),
|
||||||
|
})
|
||||||
|
} else if filetype == coverart::constants::JPEG_TYPE
|
||||||
|
|| filetype == coverart::constants::JPG_TYPE
|
||||||
|
{
|
||||||
|
Ok(FileType {
|
||||||
|
mime: String::from(coverart::constants::mime::JPEG),
|
||||||
|
file_type: String::from(coverart::constants::JPEG_TYPE),
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
Err(std::io::Error::other(format!(
|
||||||
|
"Unsupported FileType: {filetype:?}"
|
||||||
|
)))
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,90 @@
|
|||||||
|
/// Gets the file type of a Song from it's path
|
||||||
|
pub fn file_type_from_filepath(
|
||||||
|
filepath: &str,
|
||||||
|
) -> Result<crate::detection::FileType, std::io::Error> {
|
||||||
|
match infer::get_from_path(filepath) {
|
||||||
|
Ok(Some(kind)) => {
|
||||||
|
let mime = kind.mime_type();
|
||||||
|
if mime == constants::mime::FLAC {
|
||||||
|
Ok(crate::detection::FileType {
|
||||||
|
mime: String::from(mime),
|
||||||
|
file_type: String::from(constants::FLAC_TYPE),
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
Err(std::io::Error::other("Unsupported file type"))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Ok(None) => Err(std::io::Error::other("File type not determined")),
|
||||||
|
Err(err) => Err(err),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Gets the file type of a Song given it's data
|
||||||
|
pub fn file_type_from_data(data: &[u8]) -> Result<crate::detection::FileType, std::io::Error> {
|
||||||
|
match infer::get(data) {
|
||||||
|
Some(kind) => {
|
||||||
|
let mime = kind.mime_type();
|
||||||
|
if mime == constants::mime::FLAC {
|
||||||
|
Ok(crate::detection::FileType {
|
||||||
|
mime: String::from(mime),
|
||||||
|
file_type: String::from(constants::FLAC_TYPE),
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
Err(std::io::Error::other("Unsupported file type"))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
None => Err(std::io::Error::other("File type not determined")),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub mod constants {
|
||||||
|
pub const FLAC_TYPE: &str = "flac";
|
||||||
|
|
||||||
|
pub mod mime {
|
||||||
|
pub const FLAC: &str = "audio/x-flac";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod tests {
|
||||||
|
#[test]
|
||||||
|
fn test_song_file_type() {
|
||||||
|
let directory = String::from(crate::test_util::util::TESTFILEDIRECTORY);
|
||||||
|
let filename = String::from("track01.flac");
|
||||||
|
let filepath = format!("{directory}/{filename}");
|
||||||
|
|
||||||
|
match super::file_type_from_filepath(&filepath) {
|
||||||
|
Ok(filetype) => {
|
||||||
|
assert_eq!(
|
||||||
|
filetype.file_type,
|
||||||
|
crate::detection::song::constants::FLAC_TYPE,
|
||||||
|
"Types do not match"
|
||||||
|
)
|
||||||
|
}
|
||||||
|
Err(err) => {
|
||||||
|
assert!(false, "Error: {err:?}")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_song_file_type_from_data() {
|
||||||
|
let directory = String::from(crate::test_util::util::TESTFILEDIRECTORY);
|
||||||
|
let filename = String::from("track01.flac");
|
||||||
|
let filepath = format!("{directory}/{filename}");
|
||||||
|
let data = crate::test_util::util::get_data_from_file(&filepath).unwrap();
|
||||||
|
|
||||||
|
match super::file_type_from_data(&data) {
|
||||||
|
Ok(filetype) => {
|
||||||
|
assert_eq!(
|
||||||
|
filetype.file_type,
|
||||||
|
crate::detection::song::constants::FLAC_TYPE,
|
||||||
|
"Types do not match"
|
||||||
|
)
|
||||||
|
}
|
||||||
|
Err(err) => {
|
||||||
|
assert!(false, "Error: {err:?}")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
+109
@@ -1,2 +1,111 @@
|
|||||||
|
pub mod detection;
|
||||||
pub mod meta;
|
pub mod meta;
|
||||||
|
pub mod properties;
|
||||||
pub mod types;
|
pub mod types;
|
||||||
|
|
||||||
|
pub mod test_util {
|
||||||
|
pub mod util {
|
||||||
|
use std::io::{self, Read, Write};
|
||||||
|
|
||||||
|
use rand::RngExt;
|
||||||
|
|
||||||
|
// 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: &str, filename: &str) -> 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 remove_file(filepath: &str) -> Result<(), std::io::Error> {
|
||||||
|
let f_path = std::path::Path::new(filepath);
|
||||||
|
|
||||||
|
std::fs::remove_file(f_path)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn get_data_from_file(source_path: &str) -> Result<Vec<u8>, std::io::Error> {
|
||||||
|
match std::fs::File::open(source_path) {
|
||||||
|
Ok(mut file) => {
|
||||||
|
let mut data: Vec<u8> = Vec::new();
|
||||||
|
match file.read_to_end(&mut data) {
|
||||||
|
Ok(_) => Ok(data),
|
||||||
|
Err(err) => Err(err),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Err(err) => Err(err),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn file_exists(directory: &str, filename: &str) -> Result<bool, std::io::Error> {
|
||||||
|
match path_buf(directory, filename) {
|
||||||
|
Ok(pf) => Ok(pf.exists()),
|
||||||
|
Err(err) => Err(err),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn generate_newfilepath(directory: &str) -> Result<String, std::io::Error> {
|
||||||
|
match generate_filename() {
|
||||||
|
Ok(filename) => match get_full_path(directory, &filename) {
|
||||||
|
Ok(filepath) => Ok(filepath),
|
||||||
|
Err(err) => Err(err),
|
||||||
|
},
|
||||||
|
Err(err) => Err(err),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn generate_filename() -> Result<String, std::io::Error> {
|
||||||
|
let mut filename = String::from("track-");
|
||||||
|
let length = 20;
|
||||||
|
let characters = "abcdef0123456789";
|
||||||
|
let amount_of_characters = characters.len() - 1;
|
||||||
|
let mut rng = rand::rng();
|
||||||
|
|
||||||
|
for _ in 0..length {
|
||||||
|
let index = rng.random_range(0..=amount_of_characters);
|
||||||
|
let random_c = characters.chars().nth(index);
|
||||||
|
|
||||||
|
if let Some(c) = random_c {
|
||||||
|
filename.push(c);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok(format!("{filename}.flac"))
|
||||||
|
}
|
||||||
|
|
||||||
|
fn path_buf(directory: &str, filename: &str) -> 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}")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
+1151
-178
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,14 @@
|
|||||||
|
use lofty::file::AudioFile;
|
||||||
|
|
||||||
|
pub fn get_properties(songpath: &str) -> Result<lofty::flac::FlacProperties, std::io::Error> {
|
||||||
|
match std::fs::File::open(songpath) {
|
||||||
|
Ok(mut content) => {
|
||||||
|
match lofty::flac::FlacFile::read_from(&mut content, lofty::config::ParseOptions::new())
|
||||||
|
{
|
||||||
|
Ok(flac_file) => Ok(*flac_file.properties()),
|
||||||
|
Err(err) => Err(std::io::Error::other(err.to_string())),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Err(err) => Err(err),
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,139 @@
|
|||||||
|
pub mod audio;
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, Default)]
|
||||||
|
pub struct SongProperties {
|
||||||
|
pub duration: std::time::Duration,
|
||||||
|
pub sample_rate: u32,
|
||||||
|
pub bitrate: u32,
|
||||||
|
pub overall_bitrate: u32,
|
||||||
|
pub bit_depth: u8,
|
||||||
|
pub channels: u8,
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn get_song_properties(song_path: &str) -> Result<SongProperties, std::io::Error> {
|
||||||
|
match audio::get_properties(song_path) {
|
||||||
|
Ok(flac_properties) => Ok(SongProperties {
|
||||||
|
duration: flac_properties.duration(),
|
||||||
|
sample_rate: flac_properties.sample_rate(),
|
||||||
|
bitrate: flac_properties.audio_bitrate(),
|
||||||
|
overall_bitrate: flac_properties.overall_bitrate(),
|
||||||
|
bit_depth: flac_properties.bit_depth(),
|
||||||
|
channels: flac_properties.channels(),
|
||||||
|
}),
|
||||||
|
Err(err) => Err(err),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn get_duration(song_path: &str) -> Result<std::time::Duration, std::io::Error> {
|
||||||
|
match get_song_properties(song_path) {
|
||||||
|
Ok(song_properties) => Ok(song_properties.duration),
|
||||||
|
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();
|
||||||
|
let new_filepath = test_util::util::generate_newfilepath(&dir).unwrap();
|
||||||
|
|
||||||
|
match test_util::util::copy_file(&filepath, &new_filepath) {
|
||||||
|
Ok(_) => match super::get_duration(&new_filepath) {
|
||||||
|
Ok(duration) => {
|
||||||
|
test_util::util::remove_file(&new_filepath).unwrap();
|
||||||
|
|
||||||
|
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:?}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Err(err) => {
|
||||||
|
assert!(false, "Error: {err:?}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_song_properties() {
|
||||||
|
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();
|
||||||
|
let new_filepath = test_util::util::generate_newfilepath(&dir).unwrap();
|
||||||
|
|
||||||
|
match test_util::util::copy_file(&filepath, &new_filepath) {
|
||||||
|
Ok(_) => match super::get_song_properties(&new_filepath) {
|
||||||
|
Ok(song_properties) => {
|
||||||
|
test_util::util::remove_file(&new_filepath).unwrap();
|
||||||
|
|
||||||
|
let song_duration: u64 = 41;
|
||||||
|
let bitrate: u32 = 1;
|
||||||
|
let overall_bitrate: u32 = 3;
|
||||||
|
let bit_depth: u8 = 24;
|
||||||
|
let channels: u8 = 2;
|
||||||
|
|
||||||
|
let fetched_song_duration = song_properties.duration.as_secs();
|
||||||
|
let fetched_bitrate = song_properties.bitrate;
|
||||||
|
let fetched_overall_bitrate = song_properties.overall_bitrate;
|
||||||
|
let fetched_bit_depth = song_properties.bit_depth;
|
||||||
|
let fetched_channels = song_properties.channels;
|
||||||
|
|
||||||
|
assert_eq!(
|
||||||
|
song_duration, fetched_song_duration,
|
||||||
|
"Durations should match, but they don't {song_duration} {fetched_song_duration} ({song_properties:?})"
|
||||||
|
);
|
||||||
|
|
||||||
|
assert_eq!(
|
||||||
|
bitrate, fetched_bitrate,
|
||||||
|
"Bitrates do not match {bitrate:?} {fetched_bitrate:?} {song_properties:?}"
|
||||||
|
);
|
||||||
|
assert_eq!(
|
||||||
|
overall_bitrate, fetched_overall_bitrate,
|
||||||
|
"Overall bitrates do not match {overall_bitrate:?} {fetched_overall_bitrate:?} {song_properties:?}"
|
||||||
|
);
|
||||||
|
assert_eq!(
|
||||||
|
bit_depth, fetched_bit_depth,
|
||||||
|
"Bit depth do not match {bit_depth:?} {fetched_bit_depth:?} {song_properties:?}"
|
||||||
|
);
|
||||||
|
assert_eq!(
|
||||||
|
channels, fetched_channels,
|
||||||
|
"Channels do not match {channels:?} {fetched_channels:?} {song_properties:?}"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
Err(err) => {
|
||||||
|
assert!(false, "Error: {err:?}");
|
||||||
|
}
|
||||||
|
},
|
||||||
|
Err(err) => {
|
||||||
|
assert!(false, "Error: {err:?}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Err(err) => {
|
||||||
|
assert!(false, "Error: {err:?}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,8 +1,65 @@
|
|||||||
|
#[derive(Debug)]
|
||||||
pub enum Type {
|
pub enum Type {
|
||||||
Title,
|
Title,
|
||||||
Artist,
|
Artist,
|
||||||
Album,
|
Album,
|
||||||
|
AlbumArtist,
|
||||||
Genre,
|
Genre,
|
||||||
Date,
|
Date,
|
||||||
Track,
|
Track,
|
||||||
|
Disc,
|
||||||
|
TrackCount,
|
||||||
|
DiscCount,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
|
pub enum MetadataType {
|
||||||
|
String(String),
|
||||||
|
Int(i32),
|
||||||
|
}
|
||||||
|
|
||||||
|
impl MetadataType {
|
||||||
|
pub fn from_std_str(s: &str) -> Self {
|
||||||
|
MetadataType::String(s.to_string())
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn from_string(s: String) -> Self {
|
||||||
|
MetadataType::String(s)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn from_int(i: i32) -> Self {
|
||||||
|
MetadataType::Int(i)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
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 {
|
||||||
|
super::Type::Title => Ok("TITLE".to_owned()),
|
||||||
|
super::Type::Artist => Ok("ARTIST".to_owned()),
|
||||||
|
super::Type::Album => Ok("ALBUM".to_owned()),
|
||||||
|
super::Type::AlbumArtist => Ok("ALBUMARTIST".to_owned()),
|
||||||
|
super::Type::Genre => Ok("GENRE".to_owned()),
|
||||||
|
super::Type::Date => Ok("DATE".to_owned()),
|
||||||
|
super::Type::Track => Ok("TRACKNUMBER".to_owned()),
|
||||||
|
super::Type::Disc => Ok("DISCNUMBER".to_owned()),
|
||||||
|
super::Type::TrackCount => Ok("TRACKCOUNT".to_owned()),
|
||||||
|
super::Type::DiscCount => Ok("DISCCOUNT".to_owned()),
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Binary file not shown.
|
After Width: | Height: | Size: 9.4 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 39 KiB |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user