Compare commits
78 Commits
dev-v0.1.7
...
main
Author | SHA1 | Date | |
---|---|---|---|
2d6b550ae6 | |||
f43bcaa314 | |||
a6ef7d8a62 | |||
bd793db08e | |||
1e95822b5a | |||
228ca67a16 | |||
d3251f935e | |||
1c5de9dc26 | |||
569fb632e5 | |||
7839c64561 | |||
655d05dabb | |||
7958b89abc | |||
c0d23e0640 | |||
1a64b512f4 | |||
e5082ea07d | |||
f37c445908 | |||
6aa4c3d741 | |||
47475639b0 | |||
73c17840ff | |||
2dbed9fec9 | |||
97853a42c1 | |||
6467521a02 | |||
6411133c95 | |||
8a08672423 | |||
fdae8056b1 | |||
c555110367 | |||
4b6f6cb67d | |||
e9d73c391e | |||
d476b128cb | |||
255aff414a | |||
24aa60cb48 | |||
6a0135c6fa | |||
8fbd92620e | |||
61ad88a258 | |||
d8eadb8187 | |||
a64d35d153 | |||
f6fdb717e9 | |||
e5c1eabe8c | |||
a8ffe80297 | |||
56384fb371 | |||
bf5808a06a | |||
2b2e96c02d | |||
1c5c0ca70c | |||
bc3aace070 | |||
ae2fd07229 | |||
e0617b3fb8 | |||
351147cb64 | |||
d0e0d8fa2d | |||
3f379cf454 | |||
64f936bb3c | |||
929dac6413 | |||
b91d543097 | |||
9307f80274 | |||
49c732ef1b | |||
5fe0c4ccb4 | |||
7d24ce51cf | |||
474391ea44 | |||
abbb37721f | |||
e366202f24 | |||
950a70ccad | |||
7f8649ee38 | |||
ab3e519f53 | |||
98c518e149 | |||
9d3098de6b | |||
04f1ffb1ce | |||
47f336d04d | |||
e497ce11e0 | |||
fac33c7987 | |||
7f5f546f65 | |||
05537a4f6d | |||
64402a0626 | |||
a84d59a5f5 | |||
d1f63a04e4 | |||
842fe6302e | |||
b9c0ba0549 | |||
3a02bc6830 | |||
01df04b3f9 | |||
bef3a376bd |
51
.gitea/workflows/tag_release.yaml
Normal file
51
.gitea/workflows/tag_release.yaml
Normal file
@@ -0,0 +1,51 @@
|
|||||||
|
name: Release Tagging
|
||||||
|
|
||||||
|
on:
|
||||||
|
pull_request:
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
release:
|
||||||
|
runs-on: ubuntu-24.04
|
||||||
|
steps:
|
||||||
|
- name: Checkout code
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
with:
|
||||||
|
fetch-depth: 0 # Important for git describe --tags
|
||||||
|
|
||||||
|
- name: Install Rust
|
||||||
|
uses: actions-rs/toolchain@v1
|
||||||
|
with:
|
||||||
|
toolchain: 1.88.0
|
||||||
|
components: cargo
|
||||||
|
|
||||||
|
- name: Extract Version from Cargo.toml
|
||||||
|
id: version
|
||||||
|
run: |
|
||||||
|
VERSION=$(grep '^version = "' Cargo.toml | sed -E 's/version = "([^"]+)"/\1/')
|
||||||
|
PROJECT_COMMIT_HASH=$(git rev-parse HEAD | cut -c 1-10)
|
||||||
|
BRANCH_REF="${GITHUB_REF}"
|
||||||
|
BRANCH_NAME=$(echo "$BRANCH_REF" | cut -d '/' -f 3)
|
||||||
|
PROJECT_TAG_RELEASE="v$VERSION-$BRANCH_NAME-$PROJECT_COMMIT_HASH"
|
||||||
|
echo "::set-output name=project_tag_release::$PROJECT_TAG_RELEASE-111"
|
||||||
|
echo "Version: $VERSION"
|
||||||
|
echo "Hash: $PROJECT_COMMIT_HASH"
|
||||||
|
echo "Branch: $BRANCH_NAME"
|
||||||
|
echo "Tag Release: $PROJECT_TAG_RELEASE"
|
||||||
|
|
||||||
|
- name: Print version
|
||||||
|
id: Version
|
||||||
|
run: |
|
||||||
|
echo "Printing version"
|
||||||
|
echo "Version: ${{ steps.version.outputs.project_tag_release }}"
|
||||||
|
|
||||||
|
- name: Create GitHub Release
|
||||||
|
uses: actions/create-release@v1
|
||||||
|
env:
|
||||||
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
with:
|
||||||
|
tag_name: ${{ steps.version.outputs.project_tag_release }}
|
||||||
|
release_name: Release ${{ steps.version.outputs.project_tag_release }}
|
||||||
|
body: |
|
||||||
|
Release of version ${{ steps.version.outputs.project_tag_release }}
|
64
.gitea/workflows/workflow.yaml
Normal file
64
.gitea/workflows/workflow.yaml
Normal file
@@ -0,0 +1,64 @@
|
|||||||
|
name: Rust Build
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
pull_request:
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
check:
|
||||||
|
name: Check
|
||||||
|
runs-on: ubuntu-24.04
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
- uses: actions-rust-lang/setup-rust-toolchain@v1
|
||||||
|
with:
|
||||||
|
toolchain: 1.88.0
|
||||||
|
- run: cargo check
|
||||||
|
|
||||||
|
test:
|
||||||
|
name: Test Suite
|
||||||
|
runs-on: ubuntu-24.04
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
- uses: actions-rust-lang/setup-rust-toolchain@v1
|
||||||
|
with:
|
||||||
|
toolchain: 1.88.0
|
||||||
|
- run: cargo test
|
||||||
|
|
||||||
|
fmt:
|
||||||
|
name: Rustfmt
|
||||||
|
runs-on: ubuntu-24.04
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
- uses: actions-rust-lang/setup-rust-toolchain@v1
|
||||||
|
with:
|
||||||
|
toolchain: 1.88.0
|
||||||
|
- run: rustup component add rustfmt
|
||||||
|
- run: cargo fmt --all -- --check
|
||||||
|
|
||||||
|
clippy:
|
||||||
|
name: Clippy
|
||||||
|
runs-on: ubuntu-24.04
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
- uses: actions-rust-lang/setup-rust-toolchain@v1
|
||||||
|
with:
|
||||||
|
toolchain: 1.88.0
|
||||||
|
- run: rustup component add clippy
|
||||||
|
- run: cargo clippy -- -D warnings
|
||||||
|
|
||||||
|
build:
|
||||||
|
name: build
|
||||||
|
runs-on: ubuntu-24.04
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
- uses: actions-rust-lang/setup-rust-toolchain@v1
|
||||||
|
with:
|
||||||
|
toolchain: 1.88.0
|
||||||
|
- run: cargo build
|
||||||
|
|
||||||
|
|
@@ -47,7 +47,7 @@ extract_version:
|
|||||||
script:
|
script:
|
||||||
- apk add --no-cache jq
|
- apk add --no-cache jq
|
||||||
- VERSION=$(grep 'version = "' Cargo.toml | awk -F'"' '{print $2}' | head -n 1)
|
- VERSION=$(grep 'version = "' Cargo.toml | awk -F'"' '{print $2}' | head -n 1)
|
||||||
- VER_HASH=${CI_COMMIT_SHA:0:5}
|
- VER_HASH=${CI_COMMIT_SHA:0:10}
|
||||||
- VERSION="$VERSION-$VER_HASH"
|
- VERSION="$VERSION-$VER_HASH"
|
||||||
- if [ $? -ne 0 ]; then echo "Error extracting version"; exit 1; fi
|
- if [ $? -ne 0 ]; then echo "Error extracting version"; exit 1; fi
|
||||||
- echo "Extracted version is"
|
- echo "Extracted version is"
|
||||||
|
741
Cargo.lock
generated
Normal file
741
Cargo.lock
generated
Normal file
@@ -0,0 +1,741 @@
|
|||||||
|
# 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 = "aho-corasick"
|
||||||
|
version = "1.1.3"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "8e60d3430d3a69478ad0993f19238d2df97c507009a52b3c10addcd7f6bcb916"
|
||||||
|
dependencies = [
|
||||||
|
"memchr",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "anyhow"
|
||||||
|
version = "1.0.98"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "e16d2d3311acee920a9eb8d33b8cbc1787ce4a264e85f964c2404b969bdcd487"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "base64"
|
||||||
|
version = "0.22.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "bitflags"
|
||||||
|
version = "2.9.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "5c8214115b7bf84099f1309324e63141d4c5d7cc26862f97a0a857dbefe165bd"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "bumpalo"
|
||||||
|
version = "3.19.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "46c5e41b57b8bba42a04676d81cb89e9ee8e859a1a66f80a5a72e1cb76b34d43"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "cc"
|
||||||
|
version = "1.2.30"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "deec109607ca693028562ed836a5f1c4b8bd77755c4e132fc5ce11b0b6211ae7"
|
||||||
|
dependencies = [
|
||||||
|
"shlex",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "cfg-if"
|
||||||
|
version = "1.0.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "crc32fast"
|
||||||
|
version = "1.5.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "9481c1c90cbf2ac953f07c8d4a58aa3945c425b7185c9154d67a65e4230da511"
|
||||||
|
dependencies = [
|
||||||
|
"cfg-if",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "deranged"
|
||||||
|
version = "0.4.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "9c9e6a11ca8224451684bc0d7d5a7adbf8f2fd6887261a1cfc3c0432f9d4068e"
|
||||||
|
dependencies = [
|
||||||
|
"powerfmt",
|
||||||
|
"serde",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "equivalent"
|
||||||
|
version = "1.0.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "877a4ace8713b0bcf2a4e7eec82529c029f1d0619886d18145fea96c3ffe5c0f"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "errno"
|
||||||
|
version = "0.3.10"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "33d852cb9b869c2a9b3df2f71a3074817f01e1844f839a144f5fcef059a4eb5d"
|
||||||
|
dependencies = [
|
||||||
|
"libc",
|
||||||
|
"windows-sys",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "fastrand"
|
||||||
|
version = "2.3.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "37909eebbb50d72f9059c3b6d82c0463f2ff062c9e95845c43a6c9c0355411be"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "flate2"
|
||||||
|
version = "1.1.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "4a3d7db9596fecd151c5f638c0ee5d5bd487b6e0ea232e5dc96d5250f6f94b1d"
|
||||||
|
dependencies = [
|
||||||
|
"crc32fast",
|
||||||
|
"miniz_oxide",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "foreign-types"
|
||||||
|
version = "0.3.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "f6f339eb8adc052cd2ca78910fda869aefa38d22d5cb648e6485e4d3fc06f3b1"
|
||||||
|
dependencies = [
|
||||||
|
"foreign-types-shared",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "foreign-types-shared"
|
||||||
|
version = "0.1.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "getrandom"
|
||||||
|
version = "0.3.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "73fea8450eea4bac3940448fb7ae50d91f034f941199fcd9d909a5a07aa455f0"
|
||||||
|
dependencies = [
|
||||||
|
"cfg-if",
|
||||||
|
"libc",
|
||||||
|
"r-efi",
|
||||||
|
"wasi",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "hashbrown"
|
||||||
|
version = "0.15.4"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "5971ac85611da7067dbfcabef3c70ebb5606018acd9e2a3903a0da507521e0d5"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "icarus_models"
|
||||||
|
version = "0.5.6"
|
||||||
|
dependencies = [
|
||||||
|
"josekit",
|
||||||
|
"rand",
|
||||||
|
"serde",
|
||||||
|
"serde_json",
|
||||||
|
"tempfile",
|
||||||
|
"time",
|
||||||
|
"utoipa",
|
||||||
|
"uuid",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "indexmap"
|
||||||
|
version = "2.10.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "fe4cd85333e22411419a0bcae1297d25e58c9443848b11dc6a86fefe8c78a661"
|
||||||
|
dependencies = [
|
||||||
|
"equivalent",
|
||||||
|
"hashbrown",
|
||||||
|
"serde",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "itoa"
|
||||||
|
version = "1.0.15"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "4a5f13b858c8d314ee3e8f639011f7ccefe71f97f96e50151fb991f267928e2c"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "josekit"
|
||||||
|
version = "0.10.3"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "a808e078330e6af222eb0044b71d4b1ff981bfef43e7bc8133a88234e0c86a0c"
|
||||||
|
dependencies = [
|
||||||
|
"anyhow",
|
||||||
|
"base64",
|
||||||
|
"flate2",
|
||||||
|
"openssl",
|
||||||
|
"regex",
|
||||||
|
"serde",
|
||||||
|
"serde_json",
|
||||||
|
"thiserror",
|
||||||
|
"time",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "js-sys"
|
||||||
|
version = "0.3.77"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "1cfaf33c695fc6e08064efbc1f72ec937429614f25eef83af942d0e227c3a28f"
|
||||||
|
dependencies = [
|
||||||
|
"once_cell",
|
||||||
|
"wasm-bindgen",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "libc"
|
||||||
|
version = "0.2.171"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "c19937216e9d3aa9956d9bb8dfc0b0c8beb6058fc4f7a4dc4d850edf86a237d6"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "linux-raw-sys"
|
||||||
|
version = "0.9.3"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "fe7db12097d22ec582439daf8618b8fdd1a7bef6270e9af3b1ebcd30893cf413"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "log"
|
||||||
|
version = "0.4.27"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "13dc2df351e3202783a1fe0d44375f7295ffb4049267b0f3018346dc122a1d94"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "memchr"
|
||||||
|
version = "2.7.4"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "miniz_oxide"
|
||||||
|
version = "0.8.9"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "1fa76a2c86f704bdb222d66965fb3d63269ce38518b83cb0575fca855ebb6316"
|
||||||
|
dependencies = [
|
||||||
|
"adler2",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "num-conv"
|
||||||
|
version = "0.1.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "51d515d32fb182ee37cda2ccdcb92950d6a3c2893aa280e540671c2cd0f3b1d9"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "once_cell"
|
||||||
|
version = "1.21.3"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "42f5e15c9953c5e4ccceeb2e7382a716482c34515315f7b03532b8b4e8393d2d"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "openssl"
|
||||||
|
version = "0.10.73"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "8505734d46c8ab1e19a1dce3aef597ad87dcb4c37e7188231769bd6bd51cebf8"
|
||||||
|
dependencies = [
|
||||||
|
"bitflags",
|
||||||
|
"cfg-if",
|
||||||
|
"foreign-types",
|
||||||
|
"libc",
|
||||||
|
"once_cell",
|
||||||
|
"openssl-macros",
|
||||||
|
"openssl-sys",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "openssl-macros"
|
||||||
|
version = "0.1.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c"
|
||||||
|
dependencies = [
|
||||||
|
"proc-macro2",
|
||||||
|
"quote",
|
||||||
|
"syn",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "openssl-sys"
|
||||||
|
version = "0.9.109"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "90096e2e47630d78b7d1c20952dc621f957103f8bc2c8359ec81290d75238571"
|
||||||
|
dependencies = [
|
||||||
|
"cc",
|
||||||
|
"libc",
|
||||||
|
"pkg-config",
|
||||||
|
"vcpkg",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "pkg-config"
|
||||||
|
version = "0.3.32"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "7edddbd0b52d732b21ad9a5fab5c704c14cd949e5e9a1ec5929a24fded1b904c"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "powerfmt"
|
||||||
|
version = "0.2.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "439ee305def115ba05938db6eb1644ff94165c5ab5e9420d1c1bcedbba909391"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "ppv-lite86"
|
||||||
|
version = "0.2.21"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "85eae3c4ed2f50dcfe72643da4befc30deadb458a9b590d720cde2f2b1e97da9"
|
||||||
|
dependencies = [
|
||||||
|
"zerocopy",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "proc-macro2"
|
||||||
|
version = "1.0.94"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "a31971752e70b8b2686d7e46ec17fb38dad4051d94024c88df49b667caea9c84"
|
||||||
|
dependencies = [
|
||||||
|
"unicode-ident",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "quote"
|
||||||
|
version = "1.0.40"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "1885c039570dc00dcb4ff087a89e185fd56bae234ddc7f056a945bf36467248d"
|
||||||
|
dependencies = [
|
||||||
|
"proc-macro2",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "r-efi"
|
||||||
|
version = "5.2.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "74765f6d916ee2faa39bc8e68e4f3ed8949b48cccdac59983d287a7cb71ce9c5"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "rand"
|
||||||
|
version = "0.9.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "9fbfd9d094a40bf3ae768db9361049ace4c0e04a4fd6b359518bd7b73a73dd97"
|
||||||
|
dependencies = [
|
||||||
|
"rand_chacha",
|
||||||
|
"rand_core",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "rand_chacha"
|
||||||
|
version = "0.9.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "d3022b5f1df60f26e1ffddd6c66e8aa15de382ae63b3a0c1bfc0e4d3e3f325cb"
|
||||||
|
dependencies = [
|
||||||
|
"ppv-lite86",
|
||||||
|
"rand_core",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "rand_core"
|
||||||
|
version = "0.9.3"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "99d9a13982dcf210057a8a78572b2217b667c3beacbf3a0d8b454f6f82837d38"
|
||||||
|
dependencies = [
|
||||||
|
"getrandom",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "regex"
|
||||||
|
version = "1.11.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "b544ef1b4eac5dc2db33ea63606ae9ffcfac26c1416a2806ae0bf5f56b201191"
|
||||||
|
dependencies = [
|
||||||
|
"aho-corasick",
|
||||||
|
"memchr",
|
||||||
|
"regex-automata",
|
||||||
|
"regex-syntax",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "regex-automata"
|
||||||
|
version = "0.4.9"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "809e8dc61f6de73b46c85f4c96486310fe304c434cfa43669d7b40f711150908"
|
||||||
|
dependencies = [
|
||||||
|
"aho-corasick",
|
||||||
|
"memchr",
|
||||||
|
"regex-syntax",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "regex-syntax"
|
||||||
|
version = "0.8.5"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "2b15c43186be67a4fd63bee50d0303afffcef381492ebe2c5d87f324e1b8815c"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "rustix"
|
||||||
|
version = "1.0.3"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "e56a18552996ac8d29ecc3b190b4fdbb2d91ca4ec396de7bbffaf43f3d637e96"
|
||||||
|
dependencies = [
|
||||||
|
"bitflags",
|
||||||
|
"errno",
|
||||||
|
"libc",
|
||||||
|
"linux-raw-sys",
|
||||||
|
"windows-sys",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "rustversion"
|
||||||
|
version = "1.0.21"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "8a0d197bd2c9dc6e53b84da9556a69ba4cdfab8619eb41a8bd1cc2027a0f6b1d"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "ryu"
|
||||||
|
version = "1.0.20"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "28d3b2b1366ec20994f1fd18c3c594f05c5dd4bc44d8bb0c1c632c8d6829481f"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "serde"
|
||||||
|
version = "1.0.219"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "5f0e2c6ed6606019b4e29e69dbaba95b11854410e5347d525002456dbbb786b6"
|
||||||
|
dependencies = [
|
||||||
|
"serde_derive",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "serde_derive"
|
||||||
|
version = "1.0.219"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "5b0276cf7f2c73365f7157c8123c21cd9a50fbbd844757af28ca1f5925fc2a00"
|
||||||
|
dependencies = [
|
||||||
|
"proc-macro2",
|
||||||
|
"quote",
|
||||||
|
"syn",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "serde_json"
|
||||||
|
version = "1.0.140"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "20068b6e96dc6c9bd23e01df8827e6c7e1f2fddd43c21810382803c136b99373"
|
||||||
|
dependencies = [
|
||||||
|
"indexmap",
|
||||||
|
"itoa",
|
||||||
|
"memchr",
|
||||||
|
"ryu",
|
||||||
|
"serde",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "shlex"
|
||||||
|
version = "1.3.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "syn"
|
||||||
|
version = "2.0.100"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "b09a44accad81e1ba1cd74a32461ba89dee89095ba17b32f5d03683b1b1fc2a0"
|
||||||
|
dependencies = [
|
||||||
|
"proc-macro2",
|
||||||
|
"quote",
|
||||||
|
"unicode-ident",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "tempfile"
|
||||||
|
version = "3.20.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "e8a64e3985349f2441a1a9ef0b853f869006c3855f2cda6862a94d26ebb9d6a1"
|
||||||
|
dependencies = [
|
||||||
|
"fastrand",
|
||||||
|
"getrandom",
|
||||||
|
"once_cell",
|
||||||
|
"rustix",
|
||||||
|
"windows-sys",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "thiserror"
|
||||||
|
version = "2.0.12"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "567b8a2dae586314f7be2a752ec7474332959c6460e02bde30d702a66d488708"
|
||||||
|
dependencies = [
|
||||||
|
"thiserror-impl",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "thiserror-impl"
|
||||||
|
version = "2.0.12"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "7f7cf42b4507d8ea322120659672cf1b9dbb93f8f2d4ecfd6e51350ff5b17a1d"
|
||||||
|
dependencies = [
|
||||||
|
"proc-macro2",
|
||||||
|
"quote",
|
||||||
|
"syn",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "time"
|
||||||
|
version = "0.3.41"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "8a7619e19bc266e0f9c5e6686659d394bc57973859340060a69221e57dbc0c40"
|
||||||
|
dependencies = [
|
||||||
|
"deranged",
|
||||||
|
"itoa",
|
||||||
|
"num-conv",
|
||||||
|
"powerfmt",
|
||||||
|
"serde",
|
||||||
|
"time-core",
|
||||||
|
"time-macros",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "time-core"
|
||||||
|
version = "0.1.4"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "c9e9a38711f559d9e3ce1cdb06dd7c5b8ea546bc90052da6d06bb76da74bb07c"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "time-macros"
|
||||||
|
version = "0.2.22"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "3526739392ec93fd8b359c8e98514cb3e8e021beb4e5f597b00a0221f8ed8a49"
|
||||||
|
dependencies = [
|
||||||
|
"num-conv",
|
||||||
|
"time-core",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "unicode-ident"
|
||||||
|
version = "1.0.18"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "5a5f39404a5da50712a4c1eecf25e90dd62b613502b7e925fd4e4d19b5c96512"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "utoipa"
|
||||||
|
version = "5.4.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "2fcc29c80c21c31608227e0912b2d7fddba57ad76b606890627ba8ee7964e993"
|
||||||
|
dependencies = [
|
||||||
|
"indexmap",
|
||||||
|
"serde",
|
||||||
|
"serde_json",
|
||||||
|
"utoipa-gen",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "utoipa-gen"
|
||||||
|
version = "5.4.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "6d79d08d92ab8af4c5e8a6da20c47ae3f61a0f1dabc1997cdf2d082b757ca08b"
|
||||||
|
dependencies = [
|
||||||
|
"proc-macro2",
|
||||||
|
"quote",
|
||||||
|
"syn",
|
||||||
|
"uuid",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "uuid"
|
||||||
|
version = "1.17.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "3cf4199d1e5d15ddd86a694e4d0dffa9c323ce759fea589f00fef9d81cc1931d"
|
||||||
|
dependencies = [
|
||||||
|
"getrandom",
|
||||||
|
"js-sys",
|
||||||
|
"serde",
|
||||||
|
"wasm-bindgen",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "vcpkg"
|
||||||
|
version = "0.2.15"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "wasi"
|
||||||
|
version = "0.14.2+wasi-0.2.4"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "9683f9a5a998d873c0d21fcbe3c083009670149a8fab228644b8bd36b2c48cb3"
|
||||||
|
dependencies = [
|
||||||
|
"wit-bindgen-rt",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "wasm-bindgen"
|
||||||
|
version = "0.2.100"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "1edc8929d7499fc4e8f0be2262a241556cfc54a0bea223790e71446f2aab1ef5"
|
||||||
|
dependencies = [
|
||||||
|
"cfg-if",
|
||||||
|
"once_cell",
|
||||||
|
"rustversion",
|
||||||
|
"wasm-bindgen-macro",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "wasm-bindgen-backend"
|
||||||
|
version = "0.2.100"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "2f0a0651a5c2bc21487bde11ee802ccaf4c51935d0d3d42a6101f98161700bc6"
|
||||||
|
dependencies = [
|
||||||
|
"bumpalo",
|
||||||
|
"log",
|
||||||
|
"proc-macro2",
|
||||||
|
"quote",
|
||||||
|
"syn",
|
||||||
|
"wasm-bindgen-shared",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "wasm-bindgen-macro"
|
||||||
|
version = "0.2.100"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "7fe63fc6d09ed3792bd0897b314f53de8e16568c2b3f7982f468c0bf9bd0b407"
|
||||||
|
dependencies = [
|
||||||
|
"quote",
|
||||||
|
"wasm-bindgen-macro-support",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "wasm-bindgen-macro-support"
|
||||||
|
version = "0.2.100"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "8ae87ea40c9f689fc23f209965b6fb8a99ad69aeeb0231408be24920604395de"
|
||||||
|
dependencies = [
|
||||||
|
"proc-macro2",
|
||||||
|
"quote",
|
||||||
|
"syn",
|
||||||
|
"wasm-bindgen-backend",
|
||||||
|
"wasm-bindgen-shared",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "wasm-bindgen-shared"
|
||||||
|
version = "0.2.100"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "1a05d73b933a847d6cccdda8f838a22ff101ad9bf93e33684f39c1f5f0eece3d"
|
||||||
|
dependencies = [
|
||||||
|
"unicode-ident",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "windows-sys"
|
||||||
|
version = "0.59.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b"
|
||||||
|
dependencies = [
|
||||||
|
"windows-targets",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[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",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "zerocopy"
|
||||||
|
version = "0.8.24"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "2586fea28e186957ef732a5f8b3be2da217d65c5969d4b1e17f973ebbe876879"
|
||||||
|
dependencies = [
|
||||||
|
"zerocopy-derive",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "zerocopy-derive"
|
||||||
|
version = "0.8.24"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "a996a8f63c5c4448cd959ac1bab0aaa3306ccfd060472f85943ee0750f0169be"
|
||||||
|
dependencies = [
|
||||||
|
"proc-macro2",
|
||||||
|
"quote",
|
||||||
|
"syn",
|
||||||
|
]
|
17
Cargo.toml
17
Cargo.toml
@@ -1,10 +1,19 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "icarus-models"
|
name = "icarus_models"
|
||||||
version = "0.1.7"
|
version = "0.5.6"
|
||||||
edition = "2024"
|
edition = "2024"
|
||||||
|
rust-version = "1.88"
|
||||||
description = "models used for the icarus project"
|
description = "models used for the icarus project"
|
||||||
license = "MIT"
|
license = "MIT"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
serde = { version = "1.0.218", features = ["derive"] }
|
serde = { version = "1.0.219", features = ["derive"] }
|
||||||
serde_json = "1.0.139"
|
serde_json = { version = "1.0.140" }
|
||||||
|
rand = { version = "0.9.1" }
|
||||||
|
time = { version = "0.3.41", features = ["formatting", "macros", "parsing", "serde"] }
|
||||||
|
uuid = { version = "1.17.0", features = ["v4", "serde"] }
|
||||||
|
josekit = { version = "0.10.3" }
|
||||||
|
utoipa = { version = "5.4.0", features = ["uuid", "time"] }
|
||||||
|
|
||||||
|
[dev-dependencies]
|
||||||
|
tempfile = { version = "3.20.0" }
|
||||||
|
@@ -0,0 +1,2 @@
|
|||||||
|
A library containing commonly used models and functions that is used throughout
|
||||||
|
icarus projects. This reduces the amount of duplicated code without a benefit.
|
||||||
|
@@ -2,41 +2,41 @@ use std::default::Default;
|
|||||||
|
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
#[derive(Clone, Debug, Deserialize, Serialize)]
|
#[derive(Clone, Debug, Deserialize, Serialize, utoipa::ToSchema)]
|
||||||
pub struct AccessLevel {
|
pub struct AccessLevel {
|
||||||
pub id: i32,
|
pub id: uuid::Uuid,
|
||||||
pub level: String,
|
pub level: String,
|
||||||
pub song_id: i32,
|
pub song_id: uuid::Uuid,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for AccessLevel {
|
impl Default for AccessLevel {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
AccessLevel {
|
AccessLevel {
|
||||||
id: -1,
|
id: uuid::Uuid::nil(),
|
||||||
level: String::new(),
|
level: String::new(),
|
||||||
song_id: -1,
|
song_id: uuid::Uuid::new_v4(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn default_level() -> AccessLevel {
|
pub fn default_level() -> AccessLevel {
|
||||||
return AccessLevel {
|
AccessLevel {
|
||||||
id: -1,
|
id: uuid::Uuid::nil(),
|
||||||
level: String::from("Public"),
|
level: String::from("Public"),
|
||||||
song_id: -1,
|
song_id: uuid::Uuid::new_v4(),
|
||||||
};
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn private_level() -> AccessLevel {
|
pub fn private_level() -> AccessLevel {
|
||||||
return AccessLevel {
|
AccessLevel {
|
||||||
id: -1,
|
id: uuid::Uuid::new_v4(),
|
||||||
level: String::from("Private"),
|
level: String::from("Private"),
|
||||||
song_id: -1,
|
song_id: uuid::Uuid::new_v4(),
|
||||||
};
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl AccessLevel {
|
impl AccessLevel {
|
||||||
pub fn _to_json(&self) -> Result<String, serde_json::Error> {
|
pub fn _to_json(&self) -> Result<String, serde_json::Error> {
|
||||||
return serde_json::to_string_pretty(&self);
|
serde_json::to_string_pretty(&self)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
43
src/album.rs
Normal file
43
src/album.rs
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
pub mod collection {
|
||||||
|
use serde::{Deserialize, Serialize};
|
||||||
|
use std::default::Default;
|
||||||
|
|
||||||
|
use std::fs::File;
|
||||||
|
use std::io::BufReader;
|
||||||
|
|
||||||
|
use crate::init;
|
||||||
|
|
||||||
|
pub fn parse_album(filepath: &String) -> Result<Album, serde_json::Error> {
|
||||||
|
let file = File::open(filepath).expect("Failed to open file");
|
||||||
|
let reader = BufReader::new(file);
|
||||||
|
|
||||||
|
serde_json::from_reader(reader)
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, Default, Deserialize, Serialize)]
|
||||||
|
pub struct Album {
|
||||||
|
#[serde(skip_serializing_if = "String::is_empty")]
|
||||||
|
#[serde(alias = "album")]
|
||||||
|
pub title: String,
|
||||||
|
#[serde(skip_serializing_if = "String::is_empty")]
|
||||||
|
#[serde(alias = "album_artist")]
|
||||||
|
pub artist: String,
|
||||||
|
pub genre: String,
|
||||||
|
pub year: i32,
|
||||||
|
pub track_count: i32,
|
||||||
|
#[serde(skip_serializing_if = "init::is_set")]
|
||||||
|
pub disc_count: i32,
|
||||||
|
#[serde(skip_serializing_if = "Vec::is_empty")]
|
||||||
|
pub tracks: Vec<Track>,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, Default, Deserialize, Serialize)]
|
||||||
|
pub struct Track {
|
||||||
|
pub title: String,
|
||||||
|
pub artist: String,
|
||||||
|
pub disc: i32,
|
||||||
|
pub track: i32,
|
||||||
|
// In seconds
|
||||||
|
pub duration: f64,
|
||||||
|
}
|
||||||
|
}
|
@@ -1,5 +1,14 @@
|
|||||||
pub const DEFAULT_MUSIC_EXTENSION: &str = FLAC_EXTENSION;
|
pub mod file_extensions {
|
||||||
pub const FLAC_EXTENSION: &str = ".flac";
|
pub mod audio {
|
||||||
pub const WAV_EXTENSION: &str = ".wav";
|
pub const DEFAULTMUSICEXTENSION: &str = FLACEXTENSION;
|
||||||
pub const MPTHREE_EXTENSION: &str = ".mp3";
|
pub const FLACEXTENSION: &str = ".flac";
|
||||||
pub const JPG_EXTENSION: &str = ".jpg";
|
pub const WAVEXTENSION: &str = ".wav";
|
||||||
|
pub const MPTHREEEXTENSION: &str = ".mp3";
|
||||||
|
}
|
||||||
|
|
||||||
|
pub mod image {
|
||||||
|
pub const JPGEXTENSION: &str = ".jpg";
|
||||||
|
pub const JPEGEXTENSION: &str = ".jpeg";
|
||||||
|
pub const PNGEXTENSION: &str = ".png";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
53
src/coverart.rs
Normal file
53
src/coverart.rs
Normal file
@@ -0,0 +1,53 @@
|
|||||||
|
use std::io::Read;
|
||||||
|
|
||||||
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, Default, Deserialize, Serialize, utoipa::ToSchema)]
|
||||||
|
pub struct CoverArt {
|
||||||
|
pub id: uuid::Uuid,
|
||||||
|
pub title: String,
|
||||||
|
#[serde(skip)]
|
||||||
|
pub path: String,
|
||||||
|
#[serde(skip)]
|
||||||
|
pub data: Vec<u8>,
|
||||||
|
pub song_id: uuid::Uuid,
|
||||||
|
}
|
||||||
|
|
||||||
|
pub mod init {
|
||||||
|
use crate::coverart::CoverArt;
|
||||||
|
|
||||||
|
pub fn init_coverart_only_path(path: String) -> CoverArt {
|
||||||
|
CoverArt {
|
||||||
|
id: uuid::Uuid::nil(),
|
||||||
|
title: String::new(),
|
||||||
|
path: path.clone(),
|
||||||
|
data: Vec::new(),
|
||||||
|
song_id: uuid::Uuid::nil(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl CoverArt {
|
||||||
|
pub fn to_data(&self) -> Result<Vec<u8>, std::io::Error> {
|
||||||
|
let path: &String = &self.path;
|
||||||
|
let mut file = std::fs::File::open(path)?;
|
||||||
|
let mut buffer = Vec::new();
|
||||||
|
match file.read_to_end(&mut buffer) {
|
||||||
|
Ok(_) => Ok(buffer),
|
||||||
|
Err(err) => Err(err),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod tests {
|
||||||
|
use crate::coverart;
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_cover_art_image() {
|
||||||
|
let path: String = String::from("somepath");
|
||||||
|
let coverart = coverart::init::init_coverart_only_path(path.clone());
|
||||||
|
|
||||||
|
assert_eq!(path, coverart.path);
|
||||||
|
}
|
||||||
|
}
|
27
src/lib.rs
27
src/lib.rs
@@ -1,22 +1,31 @@
|
|||||||
pub mod access_level;
|
pub mod access_level;
|
||||||
|
pub mod album;
|
||||||
pub mod constants;
|
pub mod constants;
|
||||||
|
pub mod coverart;
|
||||||
pub mod login_result;
|
pub mod login_result;
|
||||||
pub mod song;
|
pub mod song;
|
||||||
pub mod token;
|
pub mod token;
|
||||||
pub mod types;
|
pub mod types;
|
||||||
pub mod user;
|
pub mod user;
|
||||||
|
|
||||||
pub fn add(left: u64, right: u64) -> u64 {
|
pub mod init {
|
||||||
left + right
|
pub fn is_id_valid(num: &i32) -> bool {
|
||||||
|
*num > 0
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
pub fn is_uuid_nil(uuid: &uuid::Uuid) -> bool {
|
||||||
mod tests {
|
uuid.is_nil()
|
||||||
use super::*;
|
}
|
||||||
|
|
||||||
#[test]
|
pub fn is_zero(num: &i32) -> bool {
|
||||||
fn it_works() {
|
*num == 0
|
||||||
let result = add(2, 2);
|
}
|
||||||
assert_eq!(result, 4);
|
|
||||||
|
pub fn is_dur_not_set(num: &i32) -> bool {
|
||||||
|
*num == 0
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn is_set(num: &i32) -> bool {
|
||||||
|
*num >= 0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -2,20 +2,20 @@ use std::default::Default;
|
|||||||
|
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
#[derive(Clone, Debug, Deserialize, Serialize)]
|
#[derive(Clone, Debug, Deserialize, Serialize, utoipa::ToSchema)]
|
||||||
pub struct LoginResult {
|
pub struct LoginResult {
|
||||||
pub id: i32,
|
pub id: uuid::Uuid,
|
||||||
pub username: String,
|
pub username: String,
|
||||||
pub token: String,
|
pub token: String,
|
||||||
#[serde(alias = "token_type")]
|
#[serde(alias = "token_type")]
|
||||||
pub token_type: String,
|
pub token_type: String,
|
||||||
pub expiration: i32,
|
pub expiration: i64,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for LoginResult {
|
impl Default for LoginResult {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
LoginResult {
|
LoginResult {
|
||||||
id: -1,
|
id: uuid::Uuid::nil(),
|
||||||
username: String::new(),
|
username: String::new(),
|
||||||
token: String::new(),
|
token: String::new(),
|
||||||
token_type: String::new(),
|
token_type: String::new(),
|
||||||
@@ -26,6 +26,6 @@ impl Default for LoginResult {
|
|||||||
|
|
||||||
impl LoginResult {
|
impl LoginResult {
|
||||||
pub fn _to_json(&self) -> Result<String, serde_json::Error> {
|
pub fn _to_json(&self) -> Result<String, serde_json::Error> {
|
||||||
return serde_json::to_string_pretty(&self);
|
serde_json::to_string_pretty(&self)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
200
src/song.rs
200
src/song.rs
@@ -1,73 +1,153 @@
|
|||||||
use std::default::Default;
|
|
||||||
use std::io::Read;
|
use std::io::Read;
|
||||||
|
|
||||||
|
use crate::constants;
|
||||||
|
use crate::init;
|
||||||
|
use crate::types;
|
||||||
|
|
||||||
|
use rand::Rng;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
#[derive(Clone, Debug, Deserialize, Serialize)]
|
#[derive(Clone, Debug, Default, Deserialize, Serialize, utoipa::ToSchema)]
|
||||||
pub struct Song {
|
pub struct Song {
|
||||||
|
#[serde(skip_serializing_if = "init::is_uuid_nil")]
|
||||||
#[serde(alias = "id")]
|
#[serde(alias = "id")]
|
||||||
pub id: Option<i32>,
|
pub id: uuid::Uuid,
|
||||||
pub title: Option<String>,
|
#[serde(skip_serializing_if = "String::is_empty")]
|
||||||
pub artist: Option<String>,
|
pub title: String,
|
||||||
pub album: Option<String>,
|
#[serde(skip_serializing_if = "String::is_empty")]
|
||||||
pub album_artist: Option<String>,
|
pub artist: String,
|
||||||
pub genre: Option<String>,
|
#[serde(skip_serializing_if = "String::is_empty")]
|
||||||
pub year: Option<i32>,
|
pub album: String,
|
||||||
pub duration: Option<i32>,
|
#[serde(skip_serializing_if = "String::is_empty")]
|
||||||
pub track: Option<i32>,
|
pub album_artist: String,
|
||||||
pub disc: Option<i32>,
|
#[serde(skip_serializing_if = "String::is_empty")]
|
||||||
pub disc_count: Option<i32>,
|
pub genre: String,
|
||||||
pub track_count: Option<i32>,
|
#[serde(skip_serializing_if = "init::is_zero")]
|
||||||
pub audio_type: Option<String>,
|
pub year: i32,
|
||||||
pub date_created: Option<String>,
|
#[serde(skip_serializing_if = "init::is_dur_not_set")]
|
||||||
pub filename: Option<String>,
|
pub duration: i32,
|
||||||
pub user_id: Option<i32>,
|
#[serde(skip_serializing_if = "init::is_zero")]
|
||||||
|
pub track: i32,
|
||||||
|
#[serde(skip_serializing_if = "init::is_zero")]
|
||||||
|
pub disc: i32,
|
||||||
|
#[serde(skip_serializing_if = "init::is_zero")]
|
||||||
|
pub disc_count: i32,
|
||||||
|
#[serde(skip_serializing_if = "init::is_zero")]
|
||||||
|
pub track_count: i32,
|
||||||
|
#[serde(skip_serializing_if = "String::is_empty")]
|
||||||
|
pub audio_type: String,
|
||||||
|
#[serde(skip_serializing_if = "String::is_empty")]
|
||||||
|
pub date_created: String,
|
||||||
|
#[serde(skip_serializing_if = "String::is_empty")]
|
||||||
|
pub filename: String,
|
||||||
|
#[serde(skip_serializing_if = "init::is_uuid_nil")]
|
||||||
|
pub user_id: uuid::Uuid,
|
||||||
#[serde(skip)]
|
#[serde(skip)]
|
||||||
pub data: Option<Vec<u8>>,
|
pub data: Vec<u8>,
|
||||||
#[serde(skip)]
|
#[serde(skip)]
|
||||||
pub directory: Option<String>,
|
pub directory: String,
|
||||||
#[serde(skip)]
|
// TODO: Think about what to do with this
|
||||||
pub album_id: Option<i32>,
|
// #[serde(skip)]
|
||||||
#[serde(skip)]
|
// pub album_id: i32,
|
||||||
pub artist_id: Option<i32>,
|
// #[serde(skip)]
|
||||||
#[serde(skip)]
|
// pub artist_id: i32,
|
||||||
pub genre_id: Option<i32>,
|
// #[serde(skip)]
|
||||||
#[serde(skip)]
|
// pub genre_id: i32,
|
||||||
pub coverart_id: Option<i32>,
|
// #[serde(skip)]
|
||||||
}
|
// pub coverart_id: i32,
|
||||||
|
|
||||||
impl Default for Song {
|
|
||||||
fn default() -> Self {
|
|
||||||
Song {
|
|
||||||
id: None,
|
|
||||||
title: None,
|
|
||||||
artist: None,
|
|
||||||
album: None,
|
|
||||||
album_artist: None,
|
|
||||||
genre: None,
|
|
||||||
year: None,
|
|
||||||
duration: None,
|
|
||||||
track: None,
|
|
||||||
disc: None,
|
|
||||||
disc_count: None,
|
|
||||||
track_count: None,
|
|
||||||
audio_type: None,
|
|
||||||
date_created: None,
|
|
||||||
filename: None,
|
|
||||||
user_id: None,
|
|
||||||
data: None,
|
|
||||||
directory: None,
|
|
||||||
album_id: None,
|
|
||||||
artist_id: None,
|
|
||||||
genre_id: None,
|
|
||||||
coverart_id: None,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Song {
|
impl Song {
|
||||||
// TODO: Implement
|
pub fn to_metadata_json(&self, pretty: bool) -> Result<String, serde_json::Error> {
|
||||||
pub fn to_metadata_json(&self) -> Result<String, serde_json::Error> {
|
if pretty {
|
||||||
return serde_json::to_string_pretty(&self);
|
serde_json::to_string_pretty(&self)
|
||||||
|
} else {
|
||||||
|
serde_json::to_string(&self)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn song_path(&self) -> Result<String, std::io::Error> {
|
||||||
|
if self.directory.is_empty() {
|
||||||
|
return Err(std::io::Error::other("Directory does not exist"));
|
||||||
|
}
|
||||||
|
|
||||||
|
let directory = &self.directory;
|
||||||
|
let mut buffer: String = directory.clone();
|
||||||
|
let last_index = directory.len() - 1;
|
||||||
|
|
||||||
|
if let Some(character) = directory.chars().nth(last_index) {
|
||||||
|
if character != '/' {
|
||||||
|
buffer += "/";
|
||||||
|
}
|
||||||
|
|
||||||
|
buffer += &self.filename.clone();
|
||||||
|
|
||||||
|
Ok(buffer)
|
||||||
|
} else {
|
||||||
|
Err(std::io::Error::other(
|
||||||
|
"Could not access last character of directory",
|
||||||
|
))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn to_data(&self) -> Result<Vec<u8>, std::io::Error> {
|
||||||
|
let path_result = self.song_path();
|
||||||
|
|
||||||
|
match path_result {
|
||||||
|
Ok(path) => {
|
||||||
|
let mut file = std::fs::File::open(path)?;
|
||||||
|
let mut buffer: Vec<u8> = Vec::new();
|
||||||
|
file.read_to_end(&mut buffer)?;
|
||||||
|
|
||||||
|
if buffer.is_empty() {
|
||||||
|
Err(std::io::Error::other("File is empty"))
|
||||||
|
} else {
|
||||||
|
Ok(buffer)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Err(er) => Err(er),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn generate_filename(&self, typ: types::MusicTypes, randomize: bool) -> String {
|
||||||
|
let mut filename: String = String::new();
|
||||||
|
let filename_len = 10;
|
||||||
|
|
||||||
|
let file_extension = match typ {
|
||||||
|
types::MusicTypes::DefaultMusicExtension => {
|
||||||
|
String::from(constants::file_extensions::audio::DEFAULTMUSICEXTENSION)
|
||||||
|
}
|
||||||
|
|
||||||
|
types::MusicTypes::WavExtension => {
|
||||||
|
String::from(constants::file_extensions::audio::WAVEXTENSION)
|
||||||
|
}
|
||||||
|
types::MusicTypes::FlacExtension => {
|
||||||
|
String::from(constants::file_extensions::audio::FLACEXTENSION)
|
||||||
|
}
|
||||||
|
types::MusicTypes::MPThreeExtension => {
|
||||||
|
String::from(constants::file_extensions::audio::MPTHREEEXTENSION)
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
if randomize {
|
||||||
|
let some_chars: String = String::from("abcdefghij0123456789");
|
||||||
|
let mut rng = rand::rng();
|
||||||
|
|
||||||
|
for _i in 0..filename_len {
|
||||||
|
let random_number: i32 = rng.random_range(0..=19);
|
||||||
|
let index = random_number as usize;
|
||||||
|
let rando_char = some_chars.chars().nth(index);
|
||||||
|
|
||||||
|
if let Some(c) = rando_char {
|
||||||
|
filename.push(c);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
filename += "track-output";
|
||||||
|
}
|
||||||
|
|
||||||
|
filename += &file_extension;
|
||||||
|
|
||||||
|
filename
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
159
src/token.rs
159
src/token.rs
@@ -5,16 +5,16 @@ use serde::{Deserialize, Serialize};
|
|||||||
#[derive(Clone, Debug, Deserialize, Serialize)]
|
#[derive(Clone, Debug, Deserialize, Serialize)]
|
||||||
pub struct Token {
|
pub struct Token {
|
||||||
pub scope: String,
|
pub scope: String,
|
||||||
pub expiration: i32,
|
pub expiration: i64,
|
||||||
pub audience: String,
|
pub audience: String,
|
||||||
pub issuer: String,
|
pub issuer: String,
|
||||||
pub issued: i32,
|
pub issued: i64,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug, Deserialize, Serialize)]
|
#[derive(Clone, Debug, Deserialize, Serialize)]
|
||||||
pub struct AccessToken {
|
pub struct AccessToken {
|
||||||
#[serde(alias = "user_id")]
|
#[serde(alias = "init::is_uuid_nil")]
|
||||||
pub user_id: i32,
|
pub user_id: uuid::Uuid,
|
||||||
#[serde(alias = "username")]
|
#[serde(alias = "username")]
|
||||||
pub username: String,
|
pub username: String,
|
||||||
#[serde(alias = "token")]
|
#[serde(alias = "token")]
|
||||||
@@ -22,7 +22,7 @@ pub struct AccessToken {
|
|||||||
#[serde(alias = "token_type")]
|
#[serde(alias = "token_type")]
|
||||||
pub token_type: String,
|
pub token_type: String,
|
||||||
#[serde(alias = "expiration")]
|
#[serde(alias = "expiration")]
|
||||||
pub expiration: i32,
|
pub expiration: i64,
|
||||||
#[serde(alias = "message")]
|
#[serde(alias = "message")]
|
||||||
pub message: String,
|
pub message: String,
|
||||||
}
|
}
|
||||||
@@ -43,22 +43,159 @@ impl AccessToken {
|
|||||||
pub fn bearer_token(&self) -> String {
|
pub fn bearer_token(&self) -> String {
|
||||||
let mut token: String = String::from("Bearer ");
|
let mut token: String = String::from("Bearer ");
|
||||||
token += &self.token.clone();
|
token += &self.token.clone();
|
||||||
return token;
|
token
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Token {
|
impl Token {
|
||||||
pub fn _to_json(&self) -> Result<String, serde_json::Error> {
|
pub fn _to_json(&self) -> Result<String, serde_json::Error> {
|
||||||
return serde_json::to_string_pretty(&self);
|
serde_json::to_string_pretty(&self)
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Implement
|
// TODO: Implement
|
||||||
pub fn token_expired(&self) -> bool {
|
pub fn token_expired(&self) -> bool {
|
||||||
return false;
|
false
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Implement
|
pub fn contains_scope(&self, des_scope: &String) -> bool {
|
||||||
pub fn contains_scope(&self, des_scope: String) -> bool {
|
self.scope.contains(des_scope)
|
||||||
return false;
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn get_issued() -> time::Result<time::OffsetDateTime> {
|
||||||
|
Ok(time::OffsetDateTime::now_utc())
|
||||||
|
}
|
||||||
|
|
||||||
|
mod util {
|
||||||
|
pub fn time_to_std_time(
|
||||||
|
provided_time: &time::OffsetDateTime,
|
||||||
|
) -> Result<std::time::SystemTime, std::time::SystemTimeError> {
|
||||||
|
let converted = std::time::SystemTime::from(*provided_time);
|
||||||
|
Ok(converted)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
|
pub struct TokenResource {
|
||||||
|
pub message: String,
|
||||||
|
pub issuer: String,
|
||||||
|
pub audiences: Vec<String>,
|
||||||
|
pub id: uuid::Uuid,
|
||||||
|
}
|
||||||
|
|
||||||
|
pub const TOKEN_TYPE: &str = "JWT";
|
||||||
|
|
||||||
|
pub fn create_token(
|
||||||
|
key: &String,
|
||||||
|
token_resource: &TokenResource,
|
||||||
|
duration: time::Duration,
|
||||||
|
) -> Result<(String, i64), josekit::JoseError> {
|
||||||
|
let mut header = josekit::jws::JwsHeader::new();
|
||||||
|
header.set_token_type(TOKEN_TYPE);
|
||||||
|
|
||||||
|
let mut payload = josekit::jwt::JwtPayload::new();
|
||||||
|
let message = &token_resource.message;
|
||||||
|
let issuer = &token_resource.issuer;
|
||||||
|
let audiences: &Vec<String> = &token_resource.audiences;
|
||||||
|
payload.set_subject(message);
|
||||||
|
payload.set_issuer(issuer);
|
||||||
|
payload.set_audience(audiences.clone());
|
||||||
|
if !token_resource.id.is_nil() {
|
||||||
|
match payload.set_claim("id", Some(serde_json::json!(token_resource.id))) {
|
||||||
|
Ok(_) => {}
|
||||||
|
Err(err) => {
|
||||||
|
return Err(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
match get_issued() {
|
||||||
|
Ok(issued) => {
|
||||||
|
let expire = issued + duration;
|
||||||
|
payload.set_issued_at(&util::time_to_std_time(&issued).unwrap());
|
||||||
|
payload.set_expires_at(&util::time_to_std_time(&expire).unwrap());
|
||||||
|
|
||||||
|
let signer = josekit::jws::alg::hmac::HmacJwsAlgorithm::Hs256
|
||||||
|
.signer_from_bytes(key.as_bytes())
|
||||||
|
.unwrap();
|
||||||
|
Ok((
|
||||||
|
josekit::jwt::encode_with_signer(&payload, &header, &signer).unwrap(),
|
||||||
|
(expire - time::OffsetDateTime::UNIX_EPOCH).whole_seconds(),
|
||||||
|
))
|
||||||
|
}
|
||||||
|
Err(e) => Err(josekit::JoseError::InvalidClaim(e.into())),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod tests {
|
||||||
|
use super::*;
|
||||||
|
|
||||||
|
fn test_key() -> String {
|
||||||
|
String::from("c3092urmc2219ix320i40m293ic29IM09IN0u879Y8B98YB8yb86TN7B55R4yv4RCVU6Bi8YO8U")
|
||||||
|
}
|
||||||
|
|
||||||
|
fn test_resource() -> TokenResource {
|
||||||
|
TokenResource {
|
||||||
|
issuer: String::from("icarus_auth_test"),
|
||||||
|
message: String::from("Authorization"),
|
||||||
|
audiences: vec![String::from("icarus_test")],
|
||||||
|
id: uuid::Uuid::nil(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_token_scope_check() {
|
||||||
|
let mut token = Token::default();
|
||||||
|
token.scope = String::from("song:read song:upload song:download");
|
||||||
|
|
||||||
|
let check_scope = String::from("song:download");
|
||||||
|
let result = token.contains_scope(&check_scope);
|
||||||
|
|
||||||
|
assert!(
|
||||||
|
result,
|
||||||
|
"Error: The scope {:?} was not found in the token's scope {:?}",
|
||||||
|
check_scope, token.scope
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_token_creation() {
|
||||||
|
let key = test_key();
|
||||||
|
let test_token_resource = test_resource();
|
||||||
|
let token_expiration_duration = time::Duration::hours(2);
|
||||||
|
|
||||||
|
match create_token(&key, &test_token_resource, token_expiration_duration) {
|
||||||
|
Ok((token, expire_duration)) => {
|
||||||
|
assert_eq!(false, token.is_empty(), "Error: Token is empty");
|
||||||
|
assert!(
|
||||||
|
expire_duration > 0,
|
||||||
|
"Token expire duration is invalid {expire_duration:?}"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
Err(err) => {
|
||||||
|
assert!(false, "Error: {err:?}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_token_creation_with_id() {
|
||||||
|
let key = test_key();
|
||||||
|
let mut test_token_resource = test_resource();
|
||||||
|
test_token_resource.id = uuid::Uuid::new_v4();
|
||||||
|
let token_expiration_duration = time::Duration::hours(2);
|
||||||
|
|
||||||
|
match create_token(&key, &test_token_resource, token_expiration_duration) {
|
||||||
|
Ok((token, expire_duration)) => {
|
||||||
|
assert_eq!(false, token.is_empty(), "Error: Token is empty");
|
||||||
|
assert!(
|
||||||
|
expire_duration > 0,
|
||||||
|
"Token expire duration is invalid {expire_duration:?}"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
Err(err) => {
|
||||||
|
assert!(false, "Error: {err:?}");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
13
src/types.rs
13
src/types.rs
@@ -1,9 +1,6 @@
|
|||||||
use std::default::Default;
|
pub enum MusicTypes {
|
||||||
|
DefaultMusicExtension,
|
||||||
mod types {
|
WavExtension,
|
||||||
pub enum Types {
|
FlacExtension,
|
||||||
WAV_EXTENSION,
|
MPThreeExtension,
|
||||||
FLAC_EXTENSION,
|
|
||||||
MP_EXTENSION,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
59
src/user.rs
59
src/user.rs
@@ -1,11 +1,13 @@
|
|||||||
use std::default::Default;
|
use std::default::Default;
|
||||||
|
|
||||||
|
use crate::init;
|
||||||
|
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
#[derive(Clone, Debug, Deserialize, Serialize)]
|
#[derive(Clone, Debug, Deserialize, Serialize, utoipa::ToSchema)]
|
||||||
pub struct User {
|
pub struct User {
|
||||||
#[serde(skip_serializing_if = "is_id_valid")]
|
#[serde(skip_serializing_if = "init::is_uuid_nil")]
|
||||||
pub id: i32,
|
pub id: uuid::Uuid,
|
||||||
#[serde(skip_serializing_if = "String::is_empty")]
|
#[serde(skip_serializing_if = "String::is_empty")]
|
||||||
pub username: String,
|
pub username: String,
|
||||||
#[serde(skip_serializing_if = "String::is_empty")]
|
#[serde(skip_serializing_if = "String::is_empty")]
|
||||||
@@ -19,22 +21,20 @@ pub struct User {
|
|||||||
#[serde(skip_serializing_if = "String::is_empty")]
|
#[serde(skip_serializing_if = "String::is_empty")]
|
||||||
pub lastname: String,
|
pub lastname: String,
|
||||||
pub email_verified: bool,
|
pub email_verified: bool,
|
||||||
#[serde(skip_serializing_if = "String::is_empty")]
|
#[serde(with = "time::serde::rfc3339::option")]
|
||||||
pub date_created: String,
|
pub date_created: Option<time::OffsetDateTime>,
|
||||||
#[serde(skip_serializing_if = "String::is_empty")]
|
#[serde(skip_serializing_if = "String::is_empty")]
|
||||||
pub status: String,
|
pub status: String,
|
||||||
#[serde(skip_serializing_if = "String::is_empty")]
|
#[serde(with = "time::serde::rfc3339::option")]
|
||||||
pub last_login: String,
|
pub last_login: Option<time::OffsetDateTime>,
|
||||||
}
|
#[serde(skip_serializing_if = "init::is_uuid_nil")]
|
||||||
|
pub salt_id: uuid::Uuid,
|
||||||
fn is_id_valid(num: &i32) -> bool {
|
|
||||||
*num > 0
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for User {
|
impl Default for User {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
User {
|
User {
|
||||||
id: -1,
|
id: uuid::Uuid::new_v4(),
|
||||||
username: String::new(),
|
username: String::new(),
|
||||||
password: String::new(),
|
password: String::new(),
|
||||||
email: String::new(),
|
email: String::new(),
|
||||||
@@ -42,9 +42,10 @@ impl Default for User {
|
|||||||
firstname: String::new(),
|
firstname: String::new(),
|
||||||
lastname: String::new(),
|
lastname: String::new(),
|
||||||
email_verified: false,
|
email_verified: false,
|
||||||
date_created: String::new(),
|
date_created: None,
|
||||||
status: String::new(),
|
status: String::new(),
|
||||||
last_login: String::new(),
|
last_login: None,
|
||||||
|
salt_id: uuid::Uuid::nil(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -52,9 +53,35 @@ impl Default for User {
|
|||||||
impl User {
|
impl User {
|
||||||
pub fn to_json(&self, output_pretty: bool) -> Result<String, serde_json::Error> {
|
pub fn to_json(&self, output_pretty: bool) -> Result<String, serde_json::Error> {
|
||||||
if output_pretty {
|
if output_pretty {
|
||||||
return serde_json::to_string_pretty(&self);
|
serde_json::to_string_pretty(&self)
|
||||||
} else {
|
} else {
|
||||||
return serde_json::to_string(&self);
|
serde_json::to_string(&self)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub mod salt {
|
||||||
|
use std::default::Default;
|
||||||
|
|
||||||
|
use crate::init;
|
||||||
|
|
||||||
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, Default, Deserialize, Serialize)]
|
||||||
|
pub struct Salt {
|
||||||
|
#[serde(skip_serializing_if = "init::is_uuid_nil")]
|
||||||
|
pub id: uuid::Uuid,
|
||||||
|
#[serde(skip_serializing_if = "String::is_empty")]
|
||||||
|
pub salt: String,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Salt {
|
||||||
|
pub fn to_json(&self, output_pretty: bool) -> Result<String, serde_json::Error> {
|
||||||
|
if output_pretty {
|
||||||
|
serde_json::to_string_pretty(&self)
|
||||||
|
} else {
|
||||||
|
serde_json::to_string(&self)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
31
tests/album.json
Normal file
31
tests/album.json
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
{
|
||||||
|
"album": "Sample Tracks! Yes",
|
||||||
|
"album_artist": "KD",
|
||||||
|
"genre": "Country",
|
||||||
|
"year": 2025,
|
||||||
|
"track_count": 3,
|
||||||
|
"disc_count": 1,
|
||||||
|
"tracks": [
|
||||||
|
{
|
||||||
|
"title": "E less",
|
||||||
|
"artist": "KD",
|
||||||
|
"disc": 1,
|
||||||
|
"track": 1,
|
||||||
|
"duration": 31
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"title": "Aaaaaye",
|
||||||
|
"artist": "KD",
|
||||||
|
"disc": 1,
|
||||||
|
"track": 2,
|
||||||
|
"duration": 33
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"title": "Check D out",
|
||||||
|
"artist": "KD",
|
||||||
|
"disc": 1,
|
||||||
|
"track": 3,
|
||||||
|
"duration": 22
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
181
tests/tests.rs
Normal file
181
tests/tests.rs
Normal file
@@ -0,0 +1,181 @@
|
|||||||
|
mod utils {
|
||||||
|
use std::fs;
|
||||||
|
use std::io::Read;
|
||||||
|
use std::path::Path;
|
||||||
|
|
||||||
|
pub fn get_tests_directory() -> String {
|
||||||
|
String::from(env!("CARGO_MANIFEST_DIR").to_owned() + "/tests/")
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn does_directory_exists(directory: &String) -> bool {
|
||||||
|
let path = Path::new(directory);
|
||||||
|
if let Ok(dir_i) = fs::metadata(path) {
|
||||||
|
dir_i.is_dir()
|
||||||
|
} else {
|
||||||
|
false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn extract_data_from_file(filepath: &String) -> Result<Vec<u8>, std::io::Error> {
|
||||||
|
match std::fs::File::open(filepath) {
|
||||||
|
Ok(mut file) => {
|
||||||
|
let mut buffer: Vec<u8> = Vec::new();
|
||||||
|
let _ = file.read_to_end(&mut buffer);
|
||||||
|
Ok(buffer)
|
||||||
|
}
|
||||||
|
Err(err) => Err(err),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod song_tests {
|
||||||
|
use std::fs::File;
|
||||||
|
use std::io::Write;
|
||||||
|
|
||||||
|
use tempfile::tempdir;
|
||||||
|
|
||||||
|
use icarus_models::song;
|
||||||
|
use icarus_models::types;
|
||||||
|
|
||||||
|
use crate::utils;
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_song_to_data() {
|
||||||
|
println!("Test");
|
||||||
|
let some_val = true;
|
||||||
|
|
||||||
|
println!("Checking if some_val is true");
|
||||||
|
assert_eq!(true, some_val);
|
||||||
|
|
||||||
|
println!("Getting track");
|
||||||
|
let mut song = song::Song::default();
|
||||||
|
song.directory = utils::get_tests_directory();
|
||||||
|
song.filename = String::from("track01.flac");
|
||||||
|
|
||||||
|
assert!(
|
||||||
|
utils::does_directory_exists(&song.directory),
|
||||||
|
"Directory does not exist"
|
||||||
|
);
|
||||||
|
|
||||||
|
println!("Directory: {}", song.directory);
|
||||||
|
|
||||||
|
match song.song_path() {
|
||||||
|
Ok(filepath) => match utils::extract_data_from_file(&filepath) {
|
||||||
|
Ok(buffer) => {
|
||||||
|
assert_eq!(buffer.is_empty(), false);
|
||||||
|
|
||||||
|
match song.to_data() {
|
||||||
|
Ok(song_data) => {
|
||||||
|
println!("Both files match");
|
||||||
|
assert_eq!(buffer, song_data);
|
||||||
|
}
|
||||||
|
Err(err) => {
|
||||||
|
assert!(false, "Error producing song data: {:?}", err);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
Err(err) => {
|
||||||
|
assert!(false, "Failed to open file: {:?}", err);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
Err(err) => {
|
||||||
|
assert!(false, "Could not get song path: {:?}", err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_song_path_check() {
|
||||||
|
let mut song = song::Song::default();
|
||||||
|
song.directory = utils::get_tests_directory();
|
||||||
|
song.filename = String::from("track01.flac");
|
||||||
|
|
||||||
|
assert!(
|
||||||
|
utils::does_directory_exists(&song.directory),
|
||||||
|
"Directory does not exist"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_song_generate_filename() {
|
||||||
|
let mut song = song::Song::default();
|
||||||
|
song.directory = utils::get_tests_directory();
|
||||||
|
song.filename = String::from("track01.flac");
|
||||||
|
|
||||||
|
match song.song_path() {
|
||||||
|
Ok(songpath) => match utils::extract_data_from_file(&songpath) {
|
||||||
|
Ok(buffer) => {
|
||||||
|
let mut song_cpy = song.clone();
|
||||||
|
let temp_dir = tempdir().expect("Failed to create temp dir");
|
||||||
|
song_cpy.directory = match temp_dir.path().to_str() {
|
||||||
|
Some(s) => String::from(s),
|
||||||
|
None => String::new(),
|
||||||
|
};
|
||||||
|
|
||||||
|
assert_eq!(song.directory.is_empty(), false);
|
||||||
|
song_cpy.filename =
|
||||||
|
song.generate_filename(types::MusicTypes::FlacExtension, true);
|
||||||
|
println!("Directory: {:?}", song_cpy.directory);
|
||||||
|
println!("File to be created: {:?}", song_cpy.filename);
|
||||||
|
|
||||||
|
let path = match song_cpy.song_path() {
|
||||||
|
Ok(s_path) => s_path,
|
||||||
|
Err(err) => {
|
||||||
|
assert!(false, "Error: {:?}", err);
|
||||||
|
String::new()
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
match File::create(path) {
|
||||||
|
Ok(mut file_cpy) => match file_cpy.write_all(&buffer) {
|
||||||
|
Ok(success) => {
|
||||||
|
println!("Success: {:?}", success);
|
||||||
|
}
|
||||||
|
Err(err) => {
|
||||||
|
assert!(false, "Error saving file: {:?}", err);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
Err(err) => {
|
||||||
|
assert!(false, "Error: {:?}", err);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
Err(err) => {
|
||||||
|
assert!(false, "Error: {:?}", err);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
Err(err) => {
|
||||||
|
assert!(false, "Error extracting song data: {:?}", err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod album_tests {
|
||||||
|
|
||||||
|
use crate::utils;
|
||||||
|
use icarus_models::album;
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn parse_album() {
|
||||||
|
let test_dir = utils::get_tests_directory();
|
||||||
|
if utils::does_directory_exists(&test_dir) {
|
||||||
|
let album_file: String = test_dir + &String::from("album.json");
|
||||||
|
println!("Album file: {:?}", album_file);
|
||||||
|
|
||||||
|
match album::collection::parse_album(&album_file) {
|
||||||
|
Ok(album) => {
|
||||||
|
println!("Album title: {}", album.title);
|
||||||
|
assert_eq!(album.title.is_empty(), false);
|
||||||
|
assert_eq!(album.artist.is_empty(), false);
|
||||||
|
assert_eq!(album.tracks.is_empty(), false);
|
||||||
|
}
|
||||||
|
Err(err) => {
|
||||||
|
assert!(false, "Error parsing album json file: {:?}", err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
BIN
tests/track01.flac
Normal file
BIN
tests/track01.flac
Normal file
Binary file not shown.
BIN
tests/track02.flac
Normal file
BIN
tests/track02.flac
Normal file
Binary file not shown.
BIN
tests/track03.flac
Normal file
BIN
tests/track03.flac
Normal file
Binary file not shown.
Reference in New Issue
Block a user