1
0
Fork 0
forked from alemi/upub

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)]
pub struct Audience(pub Vec<String>);
impl From<apb::Node<serde_json::Value>> for Audience {
fn from(value: apb::Node<serde_json::Value>) -> Self {
use apb::{Base, Link};
impl<T: apb::Base> From<apb::Node<T>> for Audience {
fn from(value: apb::Node<T>) -> Self {
Audience(
match value {
apb::Node::Empty => vec![],
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::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(),
}
)
}