treewide: complete book management interface
Signed-off-by: NotAShelf <raf@notashelf.dev> Change-Id: If5a21f16221f3c56a8008e139f93edc46a6a6964
This commit is contained in:
parent
bda36ac152
commit
2f31242442
23 changed files with 1693 additions and 126 deletions
|
|
@ -6,7 +6,7 @@
|
|||
use async_trait::async_trait;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::collections::HashMap;
|
||||
use std::path::PathBuf;
|
||||
use std::path::{Path, PathBuf};
|
||||
use thiserror::Error;
|
||||
|
||||
pub mod manifest;
|
||||
|
|
@ -161,7 +161,7 @@ pub trait MediaTypeProvider: Plugin {
|
|||
fn supported_media_types(&self) -> Vec<MediaTypeDefinition>;
|
||||
|
||||
/// Check if this plugin can handle the given file
|
||||
async fn can_handle(&self, path: &PathBuf, mime_type: Option<&str>) -> PluginResult<bool>;
|
||||
async fn can_handle(&self, path: &Path, mime_type: Option<&str>) -> PluginResult<bool>;
|
||||
}
|
||||
|
||||
/// Definition of a custom media type
|
||||
|
|
@ -190,7 +190,7 @@ pub struct MediaTypeDefinition {
|
|||
#[async_trait]
|
||||
pub trait MetadataExtractor: Plugin {
|
||||
/// Extract metadata from a file
|
||||
async fn extract_metadata(&self, path: &PathBuf) -> PluginResult<ExtractedMetadata>;
|
||||
async fn extract_metadata(&self, path: &Path) -> PluginResult<ExtractedMetadata>;
|
||||
|
||||
/// Get the media types this extractor supports
|
||||
fn supported_types(&self) -> Vec<String>;
|
||||
|
|
@ -223,8 +223,8 @@ pub trait ThumbnailGenerator: Plugin {
|
|||
/// Generate a thumbnail for the given file
|
||||
async fn generate_thumbnail(
|
||||
&self,
|
||||
path: &PathBuf,
|
||||
output_path: &PathBuf,
|
||||
path: &Path,
|
||||
output_path: &Path,
|
||||
options: ThumbnailOptions,
|
||||
) -> PluginResult<ThumbnailInfo>;
|
||||
|
||||
|
|
|
|||
|
|
@ -98,7 +98,7 @@ impl PluginManifest {
|
|||
}
|
||||
|
||||
/// Parse a manifest from TOML string
|
||||
pub fn from_str(content: &str) -> Result<Self, ManifestError> {
|
||||
pub fn parse_str(content: &str) -> Result<Self, ManifestError> {
|
||||
let manifest: Self = toml::from_str(content)?;
|
||||
manifest.validate()?;
|
||||
Ok(manifest)
|
||||
|
|
@ -223,7 +223,7 @@ wasm = "plugin.wasm"
|
|||
read = ["/tmp/pinakes-thumbnails"]
|
||||
"#;
|
||||
|
||||
let manifest = PluginManifest::from_str(toml).unwrap();
|
||||
let manifest = PluginManifest::parse_str(toml).unwrap();
|
||||
assert_eq!(manifest.plugin.name, "heif-support");
|
||||
assert_eq!(manifest.plugin.version, "1.0.0");
|
||||
assert_eq!(manifest.plugin.kind.len(), 2);
|
||||
|
|
@ -242,7 +242,7 @@ kind = ["media_type"]
|
|||
wasm = "plugin.wasm"
|
||||
"#;
|
||||
|
||||
assert!(PluginManifest::from_str(toml).is_err());
|
||||
assert!(PluginManifest::parse_str(toml).is_err());
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
|
@ -258,6 +258,6 @@ kind = ["invalid_kind"]
|
|||
wasm = "plugin.wasm"
|
||||
"#;
|
||||
|
||||
assert!(PluginManifest::from_str(toml).is_err());
|
||||
assert!(PluginManifest::parse_str(toml).is_err());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue