Skip to content

Commit 9a26bf9

Browse files
committed
chore(anni): upgrade to rust 2024
1 parent f39e1dd commit 9a26bf9

File tree

10 files changed

+145
-19
lines changed

10 files changed

+145
-19
lines changed

.envrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
use_flake

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,6 @@ perf.data.old
1212
repo.json
1313

1414
.cargo
15-
/fleet.toml
15+
/fleet.toml
16+
17+
.direnv

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ members = [
1616
resolver = "2"
1717

1818
[workspace.package]
19-
edition = "2021"
19+
edition = "2024"
2020
authors = ["Yesterday17 <mmf@mmf.moe>"]
2121
repository = "https://github.com/ProjectAnni/anni"
2222
license = "Apache-2.0"

anni-metadata/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,5 +29,5 @@ cynic-codegen = { version = "3" }
2929
tokio = { version = "1", features = ["full"] }
3030

3131
[features]
32-
default = ["annim"]
32+
default = []
3333
annim = ["reqwest", "cynic"]

anni-provider/src/providers/proxy.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ impl AnniProvider for ProxyBackend {
110110
) -> Result<ResourceReader, ProviderError> {
111111
let path = match disc_id {
112112
Some(disc_id) => format!("/{album_id}/{disc_id}/cover"),
113-
None => format!("/{album_id}/cover"),
113+
_ => format!("/{album_id}/cover"),
114114
};
115115
let resp = self
116116
.get(&path, &Range::FULL)
@@ -133,12 +133,12 @@ impl AnniProvider for ProxyBackend {
133133
fn audio_info_from_response(response: &Response) -> Result<AudioInfo, ProviderError> {
134134
let original_size = match response.headers().get("x-origin-size") {
135135
Some(s) => s.to_str().unwrap_or("0"),
136-
None => "0",
136+
_ => "0",
137137
}
138138
.to_string();
139139
let duration = match response.headers().get("x-duration-seconds") {
140140
Some(s) => s.to_str().unwrap_or("0"),
141-
None => "0",
141+
_ => "0",
142142
}
143143
.to_string();
144144
let extension = match response.headers().get("Content-Type") {

anni-repo/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ lindera-dictionary = { version = "0.27.2", optional = true }
5252
lindera-tantivy = { version = "0.27.1", optional = true, features = [
5353
"ipadic-compress",
5454
] }
55-
anni-metadata = { workspace = true, default-features = false }
55+
anni-metadata.workspace = true
5656

5757

5858
# WASM dependencies

anni-repo/src/models/json.rs

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
use std::{collections::HashMap, str::FromStr};
22

33
use crate::error::Error;
4-
use anni_metadata::{
5-
annim::query::album::AlbumFragment,
6-
model::{Album, AlbumInfo, AnniDate, Disc, TagString, TrackType},
7-
};
4+
use anni_metadata::model::{Album, AlbumInfo, AnniDate, Disc, TagString, TrackType};
85
use serde::{Deserialize, Serialize};
96
use uuid::Uuid;
107

@@ -65,13 +62,6 @@ impl ToString for JsonAlbum {
6562
}
6663
}
6764

68-
impl From<AlbumFragment> for JsonAlbum {
69-
fn from(album: AlbumFragment) -> JsonAlbum {
70-
let album: Album = album.into();
71-
album.into()
72-
}
73-
}
74-
7565
impl From<Album> for JsonAlbum {
7666
fn from(album: Album) -> JsonAlbum {
7767
let AlbumInfo {

anni/Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
name = "anni"
33
version = "0.1.1"
44
publish = false
5+
default-run = "anni"
56

67
edition.workspace = true
78
repository.workspace = true
@@ -33,7 +34,7 @@ anni-repo = { path = "../anni-repo", features = [
3334
anni-provider = { path = "../anni-provider" }
3435
annil = { path = "../annil", default-features = false }
3536
anni-workspace = { path = "../anni-workspace" }
36-
anni-metadata.workspace = true
37+
anni-metadata = { workspace = true, features = ["annim"] }
3738
clap-handler = { version = "0.1.1", features = ["async"] }
3839

3940
i18n-embed = { version = "0.14.1", features = [

flake.lock

Lines changed: 48 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

flake.nix

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
{
2+
description = "A Nix-flake-based Rust development environment";
3+
4+
inputs = {
5+
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
6+
rust-overlay = {
7+
url = "github:oxalica/rust-overlay";
8+
inputs.nixpkgs.follows = "nixpkgs";
9+
};
10+
};
11+
12+
outputs =
13+
{
14+
self,
15+
nixpkgs,
16+
rust-overlay,
17+
}:
18+
let
19+
supportedSystems = [
20+
"x86_64-linux"
21+
"aarch64-linux"
22+
"x86_64-darwin"
23+
"aarch64-darwin"
24+
];
25+
forEachSupportedSystem =
26+
f:
27+
nixpkgs.lib.genAttrs supportedSystems (
28+
system:
29+
f {
30+
pkgs = import nixpkgs {
31+
inherit system;
32+
overlays = [
33+
rust-overlay.overlays.default
34+
self.overlays.default
35+
];
36+
};
37+
}
38+
);
39+
in
40+
{
41+
overlays.default = final: prev: {
42+
rustToolchain =
43+
let
44+
rust = prev.rust-bin;
45+
in
46+
if builtins.pathExists ./rust-toolchain.toml then
47+
rust.fromRustupToolchainFile ./rust-toolchain.toml
48+
else if builtins.pathExists ./rust-toolchain then
49+
rust.fromRustupToolchainFile ./rust-toolchain
50+
else
51+
rust.stable.latest.default.override {
52+
extensions = [
53+
"rust-src"
54+
"rustfmt"
55+
];
56+
};
57+
};
58+
59+
devShells = forEachSupportedSystem (
60+
{ pkgs }:
61+
{
62+
default = pkgs.mkShell {
63+
packages = with pkgs; [
64+
rustToolchain
65+
openssl
66+
pkg-config
67+
cargo-deny
68+
cargo-edit
69+
cargo-watch
70+
rust-analyzer
71+
cmake
72+
alsa-lib
73+
alsa-lib.dev
74+
];
75+
76+
env = {
77+
# Required by rust-analyzer
78+
RUST_SRC_PATH = "${pkgs.rustToolchain}/lib/rustlib/src/rust/library";
79+
};
80+
};
81+
}
82+
);
83+
};
84+
}

0 commit comments

Comments
 (0)