You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
35 lines
895 B
Rust
35 lines
895 B
Rust
use crate::hydrus_serializable::dictionary::HydrusDictionary;
|
|
use crate::hydrus_serializable::metadata::HydrusMetadata;
|
|
use crate::hydrus_serializable::wrapper::HydrusSerWrapper;
|
|
use crate::{Endpoint, FromJson, GetEndpoint};
|
|
use serde_json::Value;
|
|
|
|
pub struct MetadataEndpoint;
|
|
|
|
impl Endpoint for MetadataEndpoint {
|
|
fn path() -> &'static str {
|
|
"metadata"
|
|
}
|
|
}
|
|
|
|
impl GetEndpoint for MetadataEndpoint {
|
|
type Response = MetadataResponse;
|
|
}
|
|
|
|
#[derive(Clone, Debug)]
|
|
pub struct MetadataResponse(pub HydrusMetadata);
|
|
|
|
impl FromJson for MetadataResponse {
|
|
fn from_json(value: Value) -> crate::Result<Self>
|
|
where
|
|
Self: Sized,
|
|
{
|
|
let mut dict = HydrusDictionary::from_json(value)?;
|
|
let metadata = dict
|
|
.take_by_str::<HydrusSerWrapper<HydrusMetadata>>("metadata_slice")?
|
|
.inner;
|
|
|
|
Ok(MetadataResponse(metadata))
|
|
}
|
|
}
|