Compare commits
15 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 946c46a23b | |||
| 23db8b9757 | |||
| 80a14e56ad | |||
| b73ffce048 | |||
| f5e6ac567e | |||
| c0607597f1 | |||
| 71374eb731 | |||
| 5101f36aed | |||
| f372d05915 | |||
| bb0524ea62 | |||
| f87c049ab3 | |||
| e11ec6ffd0 | |||
| 2a798dea9c | |||
| 5e57b9146c | |||
| 0dc8c153d2 |
@@ -3,21 +3,25 @@ name: Release Tagging
|
|||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
- devel
|
- main
|
||||||
|
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.88.0
|
toolchain: 1.96.1
|
||||||
components: cargo
|
components: cargo
|
||||||
|
|
||||||
- name: Extract Version from Cargo.toml
|
- name: Extract Version from Cargo.toml
|
||||||
@@ -28,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"
|
||||||
|
|||||||
@@ -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.88.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.88.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.88.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.88.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.88.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
|
||||||
|
|||||||
Generated
+248
-131
@@ -10,9 +10,15 @@ checksum = "320119579fcad9c21884f5c4861d16174d0e06250625266f50fe6898340abefa"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "bitflags"
|
name = "bitflags"
|
||||||
version = "2.9.0"
|
version = "2.13.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "5c8214115b7bf84099f1309324e63141d4c5d7cc26862f97a0a857dbefe165bd"
|
checksum = "b4388bee8683e3d04af747c73422af53102d2bd24d9eadb6cbc100baef4b43f8"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "bumpalo"
|
||||||
|
version = "3.20.3"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "72f5acc6cb2ba439de613abc23857ec3d78374d8ed5ac84e9d11336e87da8649"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "byteorder"
|
name = "byteorder"
|
||||||
@@ -21,31 +27,62 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||||||
checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b"
|
checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "cfg-if"
|
name = "cfb"
|
||||||
version = "1.0.0"
|
version = "0.7.3"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
|
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]]
|
[[package]]
|
||||||
name = "crc32fast"
|
name = "crc32fast"
|
||||||
version = "1.4.2"
|
version = "1.5.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "a97769d94ddab943e4510d138150169a2758b5ef3eb191a9ee688de3e23ef7b3"
|
checksum = "9481c1c90cbf2ac953f07c8d4a58aa3945c425b7185c9154d67a65e4230da511"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cfg-if",
|
"cfg-if",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "data-encoding"
|
name = "data-encoding"
|
||||||
version = "2.9.0"
|
version = "2.11.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "2a2330da5de22e8a3cb63252ce2abb30116bf5265e89c0e01bc17015ce30a476"
|
checksum = "a4ae5f15dda3c708c0ade84bfee31ccab44a3da4f88015ed22f63732abe300c8"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "errno"
|
name = "errno"
|
||||||
version = "0.3.10"
|
version = "0.3.14"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "33d852cb9b869c2a9b3df2f71a3074817f01e1844f839a144f5fcef059a4eb5d"
|
checksum = "39cab71617ae0d63f51a36d69f866391735b51691dbda63cf6f96d042b63efeb"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"libc",
|
"libc",
|
||||||
"windows-sys",
|
"windows-sys",
|
||||||
@@ -53,57 +90,116 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "fastrand"
|
name = "fastrand"
|
||||||
version = "2.3.0"
|
version = "2.4.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "37909eebbb50d72f9059c3b6d82c0463f2ff062c9e95845c43a6c9c0355411be"
|
checksum = "9f1f227452a390804cdb637b74a86990f2a7d7ba4b7d5693aac9b4dd6defd8d6"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "flate2"
|
name = "flate2"
|
||||||
version = "1.1.2"
|
version = "1.1.9"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "4a3d7db9596fecd151c5f638c0ee5d5bd487b6e0ea232e5dc96d5250f6f94b1d"
|
checksum = "843fba2746e448b37e26a819579957415c8cef339bf08564fe8b7ddbd959573c"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"crc32fast",
|
"crc32fast",
|
||||||
"miniz_oxide",
|
"miniz_oxide",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "getrandom"
|
name = "fnv"
|
||||||
version = "0.3.2"
|
version = "1.0.7"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "73fea8450eea4bac3940448fb7ae50d91f034f941199fcd9d909a5a07aa455f0"
|
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 = [
|
dependencies = [
|
||||||
"cfg-if",
|
"cfg-if",
|
||||||
"libc",
|
"libc",
|
||||||
"r-efi",
|
"r-efi",
|
||||||
"wasi",
|
"rand_core",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "icarus_meta"
|
name = "icarus_meta"
|
||||||
version = "0.3.0"
|
version = "0.6.1"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
|
"imghdr",
|
||||||
|
"infer",
|
||||||
"lofty",
|
"lofty",
|
||||||
|
"rand",
|
||||||
"tempfile",
|
"tempfile",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "libc"
|
name = "imghdr"
|
||||||
version = "0.2.171"
|
version = "0.7.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "c19937216e9d3aa9956d9bb8dfc0b0c8beb6058fc4f7a4dc4d850edf86a237d6"
|
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]]
|
[[package]]
|
||||||
name = "linux-raw-sys"
|
name = "linux-raw-sys"
|
||||||
version = "0.9.3"
|
version = "0.12.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "fe7db12097d22ec582439daf8618b8fdd1a7bef6270e9af3b1ebcd30893cf413"
|
checksum = "32a66949e030da00e8c7d4434b251670a91556f4144941d37452769c25d58a53"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "lofty"
|
name = "lofty"
|
||||||
version = "0.22.4"
|
version = "0.24.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "ca260c51a9c71f823fbfd2e6fbc8eb2ee09834b98c00763d877ca8bfa85cde3e"
|
checksum = "dec4feeff6c7d75093278133a06e827d7af6d2bfe20b0f331f9d10338a5ec7ca"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"byteorder",
|
"byteorder",
|
||||||
"data-encoding",
|
"data-encoding",
|
||||||
@@ -116,9 +212,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "lofty_attr"
|
name = "lofty_attr"
|
||||||
version = "0.11.1"
|
version = "0.12.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "ed9983e64b2358522f745c1251924e3ab7252d55637e80f6a0a3de642d6a9efc"
|
checksum = "458ace39169e4b83c4f77ae3d42d5d1d11c422feef590219a97c973d3b524557"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
@@ -127,9 +223,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "log"
|
name = "log"
|
||||||
version = "0.4.27"
|
version = "0.4.33"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "13dc2df351e3202783a1fe0d44375f7295ffb4049267b0f3018346dc122a1d94"
|
checksum = "0ceec5bc11778974d1bcb055b18002eba7f4b3518b6a0081b3af5f21666da9ad"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "miniz_oxide"
|
name = "miniz_oxide"
|
||||||
@@ -138,22 +234,23 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||||||
checksum = "1fa76a2c86f704bdb222d66965fb3d63269ce38518b83cb0575fca855ebb6316"
|
checksum = "1fa76a2c86f704bdb222d66965fb3d63269ce38518b83cb0575fca855ebb6316"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"adler2",
|
"adler2",
|
||||||
|
"simd-adler32",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "ogg_pager"
|
name = "ogg_pager"
|
||||||
version = "0.7.0"
|
version = "0.7.2"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "e034c10fb5c1c012c1b327b85df89fb0ef98ae66ec28af30f0d1eed804a40c19"
|
checksum = "9d36b1d6964c3ac92b7aea701057e02b6b91143d70d83b20abf75a231a3c0216"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"byteorder",
|
"byteorder",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "once_cell"
|
name = "once_cell"
|
||||||
version = "1.21.3"
|
version = "1.21.4"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "42f5e15c9953c5e4ccceeb2e7382a716482c34515315f7b03532b8b4e8393d2d"
|
checksum = "9f7c3e4beb33f85d45ae3e3a1792185706c8e16d043238c593331cc7cd313b50"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "paste"
|
name = "paste"
|
||||||
@@ -162,34 +259,57 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||||||
checksum = "57c0d7b74b563b49d38dae00a0c37d4d6de9b432382b2892f0574ddcae73fd0a"
|
checksum = "57c0d7b74b563b49d38dae00a0c37d4d6de9b432382b2892f0574ddcae73fd0a"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "proc-macro2"
|
name = "pin-project-lite"
|
||||||
version = "1.0.94"
|
version = "0.2.17"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "a31971752e70b8b2686d7e46ec17fb38dad4051d94024c88df49b667caea9c84"
|
checksum = "a89322df9ebe1c1578d689c92318e070967d1042b512afbe49518723f4e6d5cd"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "proc-macro2"
|
||||||
|
version = "1.0.106"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "8fd00f0bb2e90d81d1044c2b32617f68fcb9fa3bb7640c23e9c748e53fb30934"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"unicode-ident",
|
"unicode-ident",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "quote"
|
name = "quote"
|
||||||
version = "1.0.40"
|
version = "1.0.46"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "1885c039570dc00dcb4ff087a89e185fd56bae234ddc7f056a945bf36467248d"
|
checksum = "dfbc457d0c7a0759a614551b11a6409e5951f6c7537be1f1b7682b9ae9230368"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "r-efi"
|
name = "r-efi"
|
||||||
version = "5.2.0"
|
version = "6.0.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "74765f6d916ee2faa39bc8e68e4f3ed8949b48cccdac59983d287a7cb71ce9c5"
|
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]]
|
[[package]]
|
||||||
name = "rustix"
|
name = "rustix"
|
||||||
version = "1.0.3"
|
version = "1.1.4"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "e56a18552996ac8d29ecc3b190b4fdbb2d91ca4ec396de7bbffaf43f3d637e96"
|
checksum = "b6fe4565b9518b83ef4f91bb47ce29620ca828bd32cb7e408f0062e9930ba190"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bitflags",
|
"bitflags",
|
||||||
"errno",
|
"errno",
|
||||||
@@ -199,10 +319,28 @@ dependencies = [
|
|||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "syn"
|
name = "rustversion"
|
||||||
version = "2.0.100"
|
version = "1.0.23"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "b09a44accad81e1ba1cd74a32461ba89dee89095ba17b32f5d03683b1b1fc2a0"
|
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 = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
@@ -211,9 +349,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "tempfile"
|
name = "tempfile"
|
||||||
version = "3.20.0"
|
version = "3.27.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "e8a64e3985349f2441a1a9ef0b853f869006c3855f2cda6862a94d26ebb9d6a1"
|
checksum = "32497e9a4c7b38532efcdebeef879707aa9f794296a4f0244f6f69e9bc8574bd"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"fastrand",
|
"fastrand",
|
||||||
"getrandom",
|
"getrandom",
|
||||||
@@ -224,97 +362,76 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "unicode-ident"
|
name = "unicode-ident"
|
||||||
version = "1.0.18"
|
version = "1.0.24"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "5a5f39404a5da50712a4c1eecf25e90dd62b613502b7e925fd4e4d19b5c96512"
|
checksum = "e6e4313cd5fcd3dad5cafa179702e2b244f760991f45397d14d4ebf38247da75"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "wasi"
|
name = "uuid"
|
||||||
version = "0.14.2+wasi-0.2.4"
|
version = "1.23.4"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "9683f9a5a998d873c0d21fcbe3c083009670149a8fab228644b8bd36b2c48cb3"
|
checksum = "bf80a72845275afea99e7f2b434723d3bc7e38470fcd1c7ed39a599c73319a53"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"wit-bindgen-rt",
|
"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]]
|
[[package]]
|
||||||
name = "windows-sys"
|
name = "windows-sys"
|
||||||
version = "0.59.0"
|
version = "0.61.2"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b"
|
checksum = "ae137229bcbd6cdf0f7b80a31df61766145077ddf49416a728b02cb3921ff3fc"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"windows-targets",
|
"windows-link",
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "windows-targets"
|
|
||||||
version = "0.52.6"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973"
|
|
||||||
dependencies = [
|
|
||||||
"windows_aarch64_gnullvm",
|
|
||||||
"windows_aarch64_msvc",
|
|
||||||
"windows_i686_gnu",
|
|
||||||
"windows_i686_gnullvm",
|
|
||||||
"windows_i686_msvc",
|
|
||||||
"windows_x86_64_gnu",
|
|
||||||
"windows_x86_64_gnullvm",
|
|
||||||
"windows_x86_64_msvc",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "windows_aarch64_gnullvm"
|
|
||||||
version = "0.52.6"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3"
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "windows_aarch64_msvc"
|
|
||||||
version = "0.52.6"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469"
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "windows_i686_gnu"
|
|
||||||
version = "0.52.6"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b"
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "windows_i686_gnullvm"
|
|
||||||
version = "0.52.6"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66"
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "windows_i686_msvc"
|
|
||||||
version = "0.52.6"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66"
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "windows_x86_64_gnu"
|
|
||||||
version = "0.52.6"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78"
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "windows_x86_64_gnullvm"
|
|
||||||
version = "0.52.6"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d"
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "windows_x86_64_msvc"
|
|
||||||
version = "0.52.6"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec"
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "wit-bindgen-rt"
|
|
||||||
version = "0.39.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "6f42320e61fe2cfd34354ecb597f86f413484a798ba44a8ca1165c58d42da6c1"
|
|
||||||
dependencies = [
|
|
||||||
"bitflags",
|
|
||||||
]
|
]
|
||||||
|
|||||||
+7
-4
@@ -1,11 +1,14 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "icarus_meta"
|
name = "icarus_meta"
|
||||||
version = "0.3.0"
|
version = "0.6.1"
|
||||||
edition = "2024"
|
edition = "2024"
|
||||||
rust-version = "1.88"
|
rust-version = "1.95"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
lofty = { version = "0.22.4" }
|
lofty = { version = "0.24.0" }
|
||||||
|
imghdr = { version = "0.7.0" }
|
||||||
|
infer = { version = "0.19.0" }
|
||||||
|
rand = { version = "0.10.2" }
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
tempfile = { version = "3.20.0" }
|
tempfile = { version = "3.27.0" }
|
||||||
|
|||||||
@@ -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:?}")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
+55
-10
@@ -1,10 +1,13 @@
|
|||||||
|
pub mod detection;
|
||||||
pub mod meta;
|
pub mod meta;
|
||||||
pub mod properties;
|
pub mod properties;
|
||||||
pub mod types;
|
pub mod types;
|
||||||
|
|
||||||
pub mod test_util {
|
pub mod test_util {
|
||||||
pub mod util {
|
pub mod util {
|
||||||
use std::io::{self, Write};
|
use std::io::{self, Read, Write};
|
||||||
|
|
||||||
|
use rand::RngExt;
|
||||||
|
|
||||||
// Function to save a Vec<u8> to a file
|
// Function to save a Vec<u8> to a file
|
||||||
pub fn save_bytes_to_file(bytes: &[u8], file_path: &String) -> io::Result<()> {
|
pub fn save_bytes_to_file(bytes: &[u8], file_path: &String) -> io::Result<()> {
|
||||||
@@ -16,10 +19,7 @@ pub mod test_util {
|
|||||||
Err(err) => Err(err),
|
Err(err) => Err(err),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pub fn get_full_path(
|
pub fn get_full_path(directory: &str, filename: &str) -> Result<String, std::io::Error> {
|
||||||
directory: &String,
|
|
||||||
filename: &String,
|
|
||||||
) -> Result<String, std::io::Error> {
|
|
||||||
match path_buf(directory, filename) {
|
match path_buf(directory, filename) {
|
||||||
Ok(pf) => Ok(pf.display().to_string()),
|
Ok(pf) => Ok(pf.display().to_string()),
|
||||||
Err(err) => Err(err),
|
Err(err) => Err(err),
|
||||||
@@ -36,17 +36,62 @@ pub mod test_util {
|
|||||||
std::fs::copy(src_path, dest_path)
|
std::fs::copy(src_path, dest_path)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn file_exists(directory: &String, filename: &String) -> Result<bool, std::io::Error> {
|
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) {
|
match path_buf(directory, filename) {
|
||||||
Ok(pf) => Ok(pf.exists()),
|
Ok(pf) => Ok(pf.exists()),
|
||||||
Err(err) => Err(err),
|
Err(err) => Err(err),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn path_buf(
|
pub fn generate_newfilepath(directory: &str) -> Result<String, std::io::Error> {
|
||||||
directory: &String,
|
match generate_filename() {
|
||||||
filename: &String,
|
Ok(filename) => match get_full_path(directory, &filename) {
|
||||||
) -> Result<std::path::PathBuf, std::io::Error> {
|
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);
|
let dir_path = std::path::Path::new(&directory);
|
||||||
Ok(dir_path.join(filename))
|
Ok(dir_path.join(filename))
|
||||||
}
|
}
|
||||||
|
|||||||
+5
-5
@@ -544,7 +544,7 @@ mod tests {
|
|||||||
|
|
||||||
let temp_file = tempfile::tempdir().expect("Could not create test directory");
|
let temp_file = tempfile::tempdir().expect("Could not create test directory");
|
||||||
let test_dir = String::from(temp_file.path().to_str().unwrap());
|
let test_dir = String::from(temp_file.path().to_str().unwrap());
|
||||||
let test_filename = String::from("track08.flac");
|
let test_filename = util::generate_filename().unwrap();
|
||||||
let new_filepath = test_dir + "/" + &test_filename;
|
let new_filepath = test_dir + "/" + &test_filename;
|
||||||
|
|
||||||
match file_exists(&dir, &filename) {
|
match file_exists(&dir, &filename) {
|
||||||
@@ -597,7 +597,7 @@ mod tests {
|
|||||||
|
|
||||||
let temp_file = tempfile::tempdir().expect("Could not create test directory");
|
let temp_file = tempfile::tempdir().expect("Could not create test directory");
|
||||||
let test_dir = String::from(temp_file.path().to_str().unwrap());
|
let test_dir = String::from(temp_file.path().to_str().unwrap());
|
||||||
let test_filename = String::from("track08.flac");
|
let test_filename = util::generate_filename().unwrap();
|
||||||
let new_filepath = test_dir + "/" + &test_filename;
|
let new_filepath = test_dir + "/" + &test_filename;
|
||||||
|
|
||||||
match file_exists(&dir, &filename) {
|
match file_exists(&dir, &filename) {
|
||||||
@@ -806,7 +806,7 @@ mod tests {
|
|||||||
|
|
||||||
let temp_file = tempfile::tempdir().expect("Could not create test directory");
|
let temp_file = tempfile::tempdir().expect("Could not create test directory");
|
||||||
let test_dir = String::from(temp_file.path().to_str().unwrap());
|
let test_dir = String::from(temp_file.path().to_str().unwrap());
|
||||||
let test_filename = String::from("track08.flac");
|
let test_filename = util::generate_filename().unwrap();
|
||||||
let new_filepath = test_dir + "/" + &test_filename;
|
let new_filepath = test_dir + "/" + &test_filename;
|
||||||
|
|
||||||
match file_exists(&dir, &filename) {
|
match file_exists(&dir, &filename) {
|
||||||
@@ -907,7 +907,7 @@ mod tests {
|
|||||||
|
|
||||||
let temp_file = tempfile::tempdir().expect("Could not create test directory");
|
let temp_file = tempfile::tempdir().expect("Could not create test directory");
|
||||||
let test_dir = String::from(temp_file.path().to_str().unwrap());
|
let test_dir = String::from(temp_file.path().to_str().unwrap());
|
||||||
let test_filename = String::from("track08.flac");
|
let test_filename = util::generate_filename().unwrap();
|
||||||
let new_filepath = test_dir + "/" + &test_filename;
|
let new_filepath = test_dir + "/" + &test_filename;
|
||||||
|
|
||||||
match file_exists(&dir, &filename) {
|
match file_exists(&dir, &filename) {
|
||||||
@@ -1021,7 +1021,7 @@ mod tests {
|
|||||||
|
|
||||||
let temp_file = tempfile::tempdir().expect("Could not create test directory");
|
let temp_file = tempfile::tempdir().expect("Could not create test directory");
|
||||||
let test_dir = String::from(temp_file.path().to_str().unwrap());
|
let test_dir = String::from(temp_file.path().to_str().unwrap());
|
||||||
let test_filename = String::from("track08.flac");
|
let test_filename = util::generate_filename().unwrap();
|
||||||
let new_filepath = test_dir + "/" + &test_filename;
|
let new_filepath = test_dir + "/" + &test_filename;
|
||||||
|
|
||||||
match file_exists(&dir, &filename) {
|
match file_exists(&dir, &filename) {
|
||||||
|
|||||||
@@ -1,51 +0,0 @@
|
|||||||
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:?}");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -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:?}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user