Actually delete the now unused complete serialisation resource
This commit is contained in:
parent
2b783805ea
commit
49a843f853
1 changed files with 0 additions and 112 deletions
|
@ -1,112 +0,0 @@
|
||||||
use crate::schema::resource::{Link, Resource};
|
|
||||||
use serde::{Deserialize, Serialize};
|
|
||||||
use std::collections::HashMap;
|
|
||||||
|
|
||||||
/// Same as `Resource`, but doesn't have any of the skip_serializing_if fields and options set so the structure is more friendly to editing through the `editor` command
|
|
||||||
#[derive(Serialize, Deserialize)]
|
|
||||||
pub struct ResourceComplete {
|
|
||||||
subject: String,
|
|
||||||
aliases: Vec<String>,
|
|
||||||
properties: HashMap<String, Option<String>>,
|
|
||||||
links: Vec<LinkComplete>,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl ResourceComplete {
|
|
||||||
pub fn from_resource(value: Resource) -> Self {
|
|
||||||
let Resource {
|
|
||||||
subject,
|
|
||||||
aliases,
|
|
||||||
properties,
|
|
||||||
links,
|
|
||||||
} = value;
|
|
||||||
Self {
|
|
||||||
subject,
|
|
||||||
aliases: aliases.unwrap_or_default(),
|
|
||||||
properties: properties.unwrap_or_default(),
|
|
||||||
links: links
|
|
||||||
.map(|vec| vec.into_iter().map(LinkComplete::from_link).collect())
|
|
||||||
.unwrap_or_default(),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn into_resource(self) -> Resource {
|
|
||||||
let ResourceComplete {
|
|
||||||
subject,
|
|
||||||
aliases,
|
|
||||||
properties,
|
|
||||||
links,
|
|
||||||
} = self;
|
|
||||||
Resource {
|
|
||||||
subject,
|
|
||||||
aliases: if aliases.is_empty() {
|
|
||||||
None
|
|
||||||
} else {
|
|
||||||
Some(aliases)
|
|
||||||
},
|
|
||||||
properties: if properties.is_empty() {
|
|
||||||
None
|
|
||||||
} else {
|
|
||||||
Some(properties)
|
|
||||||
},
|
|
||||||
links: if links.is_empty() {
|
|
||||||
None
|
|
||||||
} else {
|
|
||||||
Some(links.into_iter().map(LinkComplete::into_link).collect())
|
|
||||||
},
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Same as `Link`, but doesn't have any of the skip_serializing_if fields set so the structure is more friendly to editing through the `editor` command
|
|
||||||
#[derive(Serialize, Deserialize)]
|
|
||||||
pub struct LinkComplete {
|
|
||||||
rel: String,
|
|
||||||
media_type: Option<String>,
|
|
||||||
href: Option<String>,
|
|
||||||
titles: HashMap<String, String>,
|
|
||||||
properties: HashMap<String, Option<String>>,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl LinkComplete {
|
|
||||||
fn from_link(value: Link) -> Self {
|
|
||||||
let Link {
|
|
||||||
rel,
|
|
||||||
media_type,
|
|
||||||
href,
|
|
||||||
titles,
|
|
||||||
properties,
|
|
||||||
} = value;
|
|
||||||
Self {
|
|
||||||
rel,
|
|
||||||
media_type,
|
|
||||||
href,
|
|
||||||
titles: titles.unwrap_or_default(),
|
|
||||||
properties: properties.unwrap_or_default(),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn into_link(self) -> Link {
|
|
||||||
let LinkComplete {
|
|
||||||
rel,
|
|
||||||
media_type,
|
|
||||||
href,
|
|
||||||
titles,
|
|
||||||
properties,
|
|
||||||
} = self;
|
|
||||||
Link {
|
|
||||||
rel,
|
|
||||||
media_type,
|
|
||||||
href,
|
|
||||||
titles: if titles.is_empty() {
|
|
||||||
None
|
|
||||||
} else {
|
|
||||||
Some(titles)
|
|
||||||
},
|
|
||||||
properties: if properties.is_empty() {
|
|
||||||
None
|
|
||||||
} else {
|
|
||||||
Some(properties)
|
|
||||||
},
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in a new issue