fix: oops must be generic impl

This commit is contained in:
əlemi 2024-04-12 21:55:19 +02:00
parent 5de807b3d9
commit 4e34446894
Signed by: alemi
GPG key ID: A4895B84D311642C

View file

@ -29,15 +29,14 @@ impl From<FieldError> for axum::http::StatusCode {
#[derive(Clone, Debug, Default, PartialEq, Eq, serde::Serialize, serde::Deserialize, sea_orm::FromJsonQueryResult)] #[derive(Clone, Debug, Default, PartialEq, Eq, serde::Serialize, serde::Deserialize, sea_orm::FromJsonQueryResult)]
pub struct Audience(pub Vec<String>); pub struct Audience(pub Vec<String>);
impl From<apb::Node<serde_json::Value>> for Audience { impl<T: apb::Base> From<apb::Node<T>> for Audience {
fn from(value: apb::Node<serde_json::Value>) -> Self { fn from(value: apb::Node<T>) -> Self {
use apb::{Base, Link};
Audience( Audience(
match value { match value {
apb::Node::Empty => vec![], apb::Node::Empty => vec![],
apb::Node::Link(l) => vec![l.href().to_string()], apb::Node::Link(l) => vec![l.href().to_string()],
apb::Node::Object(o) => if let Some(id) = o.id() { vec![id.to_string()] } else { vec![] }, apb::Node::Object(o) => if let Some(id) = o.id() { vec![id.to_string()] } else { vec![] },
apb::Node::Array(arr) => arr.into_iter().map(|l| l.href().to_string()).collect(), apb::Node::Array(arr) => arr.into_iter().filter_map(|l| Some(l.id()?.to_string())).collect(),
} }
) )
} }