mirror of
https://codeberg.org/Toasterson/ips.git
synced 2026-04-10 13:20:42 +00:00
- Transitioned the catalog backend from `redb` to `rusqlite` for better compatibility and concurrency. - Updated `IpsProvider` to use SQLite for package querying, dependency resolution, and obsolescence handling. - Removed `decode_manifest_bytes_local` and unused `manifest` cache logic. - Simplified catalog-related functions and integrated `sqlite_catalog` module. - Enhanced test functions and added schemas for managing SQLite databases.
93 lines
2.4 KiB
Rust
93 lines
2.4 KiB
Rust
use axum::response::IntoResponse;
|
|
use std::fmt;
|
|
|
|
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
|
pub enum Operation {
|
|
Info,
|
|
Versions,
|
|
Catalog,
|
|
Manifest,
|
|
File,
|
|
Publisher,
|
|
Search,
|
|
}
|
|
|
|
impl fmt::Display for Operation {
|
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
|
let s = match self {
|
|
Operation::Info => "info",
|
|
Operation::Versions => "versions",
|
|
Operation::Catalog => "catalog",
|
|
Operation::Manifest => "manifest",
|
|
Operation::File => "file",
|
|
Operation::Publisher => "publisher",
|
|
Operation::Search => "search",
|
|
};
|
|
write!(f, "{}", s)
|
|
}
|
|
}
|
|
|
|
pub struct SupportedOperation {
|
|
pub op: Operation,
|
|
pub versions: Vec<u32>,
|
|
}
|
|
|
|
pub struct VersionsResponse {
|
|
pub server_version: String,
|
|
pub operations: Vec<SupportedOperation>,
|
|
}
|
|
|
|
impl fmt::Display for VersionsResponse {
|
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
|
writeln!(f, "pkg-server {}", self.server_version)?;
|
|
for op in &self.operations {
|
|
write!(f, "{}", op.op)?;
|
|
for v in &op.versions {
|
|
write!(f, " {}", v)?;
|
|
}
|
|
writeln!(f)?;
|
|
}
|
|
Ok(())
|
|
}
|
|
}
|
|
|
|
pub async fn get_versions() -> impl IntoResponse {
|
|
let pkg_version = env!("CARGO_PKG_VERSION");
|
|
let server_version = format!("pkg6depotd-{}", pkg_version);
|
|
|
|
let response = VersionsResponse {
|
|
server_version,
|
|
operations: vec![
|
|
SupportedOperation {
|
|
op: Operation::Info,
|
|
versions: vec![0],
|
|
},
|
|
SupportedOperation {
|
|
op: Operation::Versions,
|
|
versions: vec![0],
|
|
},
|
|
SupportedOperation {
|
|
op: Operation::Catalog,
|
|
versions: vec![1, 2],
|
|
},
|
|
SupportedOperation {
|
|
op: Operation::Manifest,
|
|
versions: vec![0, 1],
|
|
},
|
|
SupportedOperation {
|
|
op: Operation::File,
|
|
versions: vec![0, 1],
|
|
},
|
|
SupportedOperation {
|
|
op: Operation::Publisher,
|
|
versions: vec![0, 1],
|
|
},
|
|
//SupportedOperation {
|
|
// op: Operation::Search,
|
|
// versions: vec![0, 1],
|
|
//},
|
|
],
|
|
};
|
|
|
|
response.to_string()
|
|
}
|