From 4f4f5e9af61193a698fdf9d2977dff507efd86e7 Mon Sep 17 00:00:00 2001 From: Luca Barbato Date: Mon, 9 Oct 2023 10:24:34 +0200 Subject: [PATCH] doc: Prettify the diagram --- assets/sifis-message.drawio.svg | 2 +- src/bin/sifis-consumer/cli.rs | 11 ++++++++--- src/bin/sifis-consumer/main.rs | 2 ++ 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/assets/sifis-message.drawio.svg b/assets/sifis-message.drawio.svg index 3a1dc77..66baed1 100644 --- a/assets/sifis-message.drawio.svg +++ b/assets/sifis-message.drawio.svg @@ -1,4 +1,4 @@ -
Runtime
Runtime
UC
UC
Try (xacml+dht)
Try (xacml+dht)
Ok (dht)
Ok (dht)
Ok (dht)
Ok (dht)
Start (dht)
Start (dht)
Consumer
Consumer
App
App
command
command
sifis-api (tarpc)
sifis-api (tarpc)
wot (dht)
wot (dht)
Thing
Thing
wot (http)
wot (http)
Ok (http)
Ok (http)
Ok (dht)
Ok (dht)
Ok (tarpc)
Ok (tarpc)
End (dht)
End (dht)
Ok
Ok
Text is not SVG - cannot display
\ No newline at end of file +
Runtime
Runtime
Usage Control
Usage Control
Try (xacml+dht)
Try (xacml+dht)
Ok (dht)
Ok (dht)
Ok (dht)
Ok (dht)
Start (dht)
Start (dht)
Consumer
Consumer
App
App
command
command
sifis-api (tarpc)
sifis-api (tarpc)
wot (dht)
wot (dht)
Thing
Thing
wot (http)
wot (http)
Ok (http)
Ok (http)
Ok (dht)
Ok (dht)
Ok (tarpc)
Ok (tarpc)
End (dht)
End (dht)
Ok
Ok
Text is not SVG - cannot display
\ No newline at end of file diff --git a/src/bin/sifis-consumer/cli.rs b/src/bin/sifis-consumer/cli.rs index a26dbed..b8154c3 100644 --- a/src/bin/sifis-consumer/cli.rs +++ b/src/bin/sifis-consumer/cli.rs @@ -31,6 +31,7 @@ pub struct Thing { pub port: u16, pub ty: ThingType, pub uuid: Uuid, + pub args: Vec, } #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] @@ -51,7 +52,7 @@ impl FromStr for Thing { type Err = InvalidThing; fn from_str(s: &str) -> Result { - let mut split = s.splitn(4, ':'); + let mut split = s.split(':'); macro_rules! get { () => { @@ -64,20 +65,24 @@ impl FromStr for Thing { let raw_path = get!(); let raw_port = get!(); let raw_type = get!(); - let raw_uuid = get!(); + let raw_uuid = split.next(); + let args: Vec = split.map(ToString::to_string).collect(); let path = PathBuf::from(raw_path); let port = raw_port .parse() .map_err(|_| InvalidThing::Port(s.to_owned()))?; let ty = raw_type.parse().map_err(InvalidThing::Type)?; - let uuid = Uuid::parse_str(raw_uuid).map_err(InvalidThing::Uuid)?; + let uuid = raw_uuid + .map_or_else(|| Ok(Uuid::new_v4()), Uuid::parse_str) + .map_err(InvalidThing::Uuid)?; Ok(Self { path, port, ty, uuid, + args, }) } } diff --git a/src/bin/sifis-consumer/main.rs b/src/bin/sifis-consumer/main.rs index 2598412..9fd417d 100644 --- a/src/bin/sifis-consumer/main.rs +++ b/src/bin/sifis-consumer/main.rs @@ -107,10 +107,12 @@ fn run_things( port, ty, uuid, + ref args, } = cli_thing; let child = tokio::process::Command::new(path) .arg("--listen-port") .arg(format!("{port}")) + .args(args) .spawn()?; let thing = ThingRepr { port, uuid, ty };