support denoting entry entities in decomposed format (adding URLs)
parent
686020e579
commit
b5a90ce57c
|
@ -8,11 +8,18 @@ use std::io::{Cursor, Write};
|
||||||
|
|
||||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||||
pub struct InEntry {
|
pub struct InEntry {
|
||||||
pub entity: Option<Address>,
|
pub entity: Option<InAddress>,
|
||||||
pub attribute: String,
|
pub attribute: String,
|
||||||
pub value: EntryValue,
|
pub value: EntryValue,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||||
|
#[serde(untagged)]
|
||||||
|
pub enum InAddress {
|
||||||
|
Address(String),
|
||||||
|
Components { t: String, c: String },
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||||
pub struct Entry {
|
pub struct Entry {
|
||||||
pub entity: Address,
|
pub entity: Address,
|
||||||
|
@ -123,8 +130,19 @@ impl TryFrom<InEntry> for Entry {
|
||||||
|
|
||||||
fn try_from(in_entry: InEntry) -> Result<Self, Self::Error> {
|
fn try_from(in_entry: InEntry) -> Result<Self, Self::Error> {
|
||||||
match in_entry.entity {
|
match in_entry.entity {
|
||||||
Some(entity) => Ok(Entry {
|
Some(address) => Ok(Entry {
|
||||||
entity,
|
entity: match address {
|
||||||
|
InAddress::Address(address) => address.parse()?,
|
||||||
|
InAddress::Components { t, c } => {
|
||||||
|
// I absolutely cannot handle serde magic right now
|
||||||
|
// TODO: make this automatically derive from `Address` definition
|
||||||
|
match t.as_str() {
|
||||||
|
"Attribute" => Address::Attribute(c),
|
||||||
|
"Url" => Address::Url(c),
|
||||||
|
_ => c.parse()?,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
attribute: in_entry.attribute,
|
attribute: in_entry.attribute,
|
||||||
value: in_entry.value,
|
value: in_entry.value,
|
||||||
}),
|
}),
|
||||||
|
|
|
@ -217,6 +217,7 @@ pub async fn get_object(
|
||||||
|
|
||||||
debug!("{:?}", result);
|
debug!("{:?}", result);
|
||||||
|
|
||||||
|
// TODO: make this automatically derive from `Address` definition
|
||||||
let (entity_type, entity_content) = match address {
|
let (entity_type, entity_content) = match address {
|
||||||
Address::Hash(_) => ("Hash", None),
|
Address::Hash(_) => ("Hash", None),
|
||||||
Address::Uuid(_) => ("Uuid", None),
|
Address::Uuid(_) => ("Uuid", None),
|
||||||
|
|
Loading…
Reference in New Issue