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::time::{SystemTime, UNIX_EPOCH};
|
||||||
use std::{collections::HashMap, io};
|
use std::{collections::HashMap, io};
|
||||||
use tempfile::NamedTempFile;
|
use tempfile::NamedTempFile;
|
||||||
|
use uuid::Uuid;
|
||||||
|
|
||||||
#[cfg(feature = "desktop")]
|
#[cfg(feature = "desktop")]
|
||||||
use is_executable::IsExecutable;
|
use is_executable::IsExecutable;
|
||||||
|
@ -258,7 +259,7 @@ pub enum InEntry {
|
||||||
#[serde(untagged)]
|
#[serde(untagged)]
|
||||||
pub enum InAddress {
|
pub enum InAddress {
|
||||||
Address(String),
|
Address(String),
|
||||||
Components { t: String, c: String },
|
Components { t: String, c: Option<String> },
|
||||||
}
|
}
|
||||||
|
|
||||||
impl TryInto<Address> for InAddress {
|
impl TryInto<Address> for InAddress {
|
||||||
|
@ -271,9 +272,13 @@ impl TryInto<Address> for InAddress {
|
||||||
// I absolutely cannot handle serde magic right now
|
// I absolutely cannot handle serde magic right now
|
||||||
// TODO: make this automatically derive from `Address` definition
|
// TODO: make this automatically derive from `Address` definition
|
||||||
match t.as_str() {
|
match t.as_str() {
|
||||||
"Attribute" => Address::Attribute(c),
|
"Attribute" => Address::Attribute(c.ok_or(anyhow!("Missing attribute."))?),
|
||||||
"Url" => Address::Url(c),
|
"Url" => Address::Url(c.ok_or(anyhow!("Missing URL."))?),
|
||||||
_ => c.parse()?,
|
"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 {
|
let in_address = InAddress::Components {
|
||||||
t: "Url".into(),
|
t: "Url".into(),
|
||||||
c: "https://upendproject.net".into(),
|
c: Some("https://upendproject.net".into()),
|
||||||
};
|
};
|
||||||
assert_eq!(address, in_address.try_into()?);
|
assert_eq!(address, in_address.try_into()?);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue