allow uuid generation by server
parent
ebf48c0e5f
commit
a74e86e70d
|
@ -27,6 +27,7 @@ use std::sync::{Arc, RwLock};
|
|||
use std::time::{SystemTime, UNIX_EPOCH};
|
||||
use std::{collections::HashMap, io};
|
||||
use tempfile::NamedTempFile;
|
||||
use uuid::Uuid;
|
||||
|
||||
#[cfg(feature = "desktop")]
|
||||
use is_executable::IsExecutable;
|
||||
|
@ -258,7 +259,7 @@ pub enum InEntry {
|
|||
#[serde(untagged)]
|
||||
pub enum InAddress {
|
||||
Address(String),
|
||||
Components { t: String, c: String },
|
||||
Components { t: String, c: Option<String> },
|
||||
}
|
||||
|
||||
impl TryInto<Address> for InAddress {
|
||||
|
@ -271,9 +272,13 @@ impl TryInto<Address> for InAddress {
|
|||
// 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" => Address::Attribute(c.ok_or(anyhow!("Missing attribute."))?),
|
||||
"Url" => Address::Url(c.ok_or(anyhow!("Missing URL."))?),
|
||||
"Uuid" => match c {
|
||||
Some(c) => c.parse()?,
|
||||
None => Address::Uuid(Uuid::new_v4()),
|
||||
},
|
||||
_ => c.ok_or(anyhow!("Missing address."))?.parse()?,
|
||||
}
|
||||
}
|
||||
})
|
||||
|
@ -656,7 +661,7 @@ mod tests {
|
|||
|
||||
let in_address = InAddress::Components {
|
||||
t: "Url".into(),
|
||||
c: "https://upendproject.net".into(),
|
||||
c: Some("https://upendproject.net".into()),
|
||||
};
|
||||
assert_eq!(address, in_address.try_into()?);
|
||||
|
||||
|
|
Loading…
Reference in New Issue