eureka_mmanager_core/
data_push.rs

1pub mod chapter;
2pub mod cover;
3pub mod manga;
4
5use itertools::Itertools;
6use mangadex_api_schema_rust::ApiObject;
7use mangadex_api_types_rust::RelationshipType;
8
9pub trait Push<T> {
10    type Error;
11    fn push(&mut self, data: T) -> Result<(), Self::Error>;
12    fn verify_and_push(&mut self, data: T) -> Result<(), Self::Error> {
13        self.push(data)
14    }
15}
16
17pub(crate) fn seed_rel<A>(input: &mut ApiObject<A>, seed: &ApiObject<A>, rel: RelationshipType) {
18    input.relationships.retain(|x| x.type_ != rel);
19    input.relationships.append(
20        &mut seed
21            .relationships
22            .iter()
23            .filter(|r| r.type_ == rel || r.attributes.is_some())
24            .cloned()
25            .collect_vec(),
26    );
27}