45 lines
1.6 KiB
Rust
45 lines
1.6 KiB
Rust
pub trait IStorage: Send + Sync {
|
|
fn plugins(&self, query: &str) -> decky_api::StorePluginList;
|
|
|
|
fn get_artifact(&self, _name: &str, _version: &str, _hash: &str) -> Result<bytes::Bytes, std::io::Error> {
|
|
Err(std::io::Error::new(std::io::ErrorKind::InvalidInput, "Artifact downloading not supported"))
|
|
}
|
|
|
|
fn get_image(&self, _name: &str) -> Result<bytes::Bytes, std::io::Error> {
|
|
Err(std::io::Error::new(std::io::ErrorKind::InvalidInput, "Image downloading not supported"))
|
|
}
|
|
|
|
fn get_statistics(&self) -> std::collections::HashMap<String, u64> {
|
|
std::collections::HashMap::with_capacity(0)
|
|
}
|
|
|
|
fn increment_statistic(&self, _name: &str, _version: &str, _query: &decky_api::StorePluginIncrement) -> Result<decky_api::StorePluginVersion, std::io::Error> {
|
|
Err(std::io::Error::new(std::io::ErrorKind::InvalidInput, "Statistics increment not supported"))
|
|
}
|
|
|
|
fn descriptor(&self) -> String;
|
|
}
|
|
|
|
pub struct EmptyStorage;
|
|
|
|
impl IStorage for EmptyStorage {
|
|
fn plugins(&self, _query: &str) -> decky_api::StorePluginList {
|
|
Vec::new()
|
|
}
|
|
|
|
fn descriptor(&self) -> String {
|
|
"empty".to_owned()
|
|
}
|
|
}
|
|
|
|
pub trait IQueryHandler: Send + Sync {
|
|
fn filter(&self, query: &str, plugins: decky_api::StorePluginList) -> decky_api::StorePluginList;
|
|
|
|
/// Filter out recognized query parameters from query string, returning only those that the query handler can use in IQueryHandler::filter
|
|
fn supported_params(&self, query: &str) -> String {
|
|
query.to_owned()
|
|
}
|
|
|
|
fn descriptor(&self) -> String;
|
|
}
|