Returns tokens from given stringed input consisting of (1) comma separated party IDs, OR (2) "public", OR (3) "secret-shared". # Arguments `s` - string that encodes the information concerning participating parties # Returns Vector of party identifiers
(s: String)
| 22 | /// |
| 23 | /// Vector of party identifiers |
| 24 | fn get_tokens(s: String) -> Result<Vec<IOStatus>> { |
| 25 | let tokens: Vec<String> = s.split(',').map(|x| x.to_owned()).collect(); |
| 26 | if tokens.is_empty() { |
| 27 | return Err(runtime_error!("Empty tokens")); |
| 28 | } |
| 29 | let mut result = Vec::new(); |
| 30 | for token in tokens { |
| 31 | let tmp: &str = &token; |
| 32 | match tmp { |
| 33 | "0" => { |
| 34 | result.push(IOStatus::Party(0)); |
| 35 | } |
| 36 | "1" => { |
| 37 | result.push(IOStatus::Party(1)); |
| 38 | } |
| 39 | "2" => { |
| 40 | result.push(IOStatus::Party(2)); |
| 41 | } |
| 42 | "public" => { |
| 43 | result.push(IOStatus::Public); |
| 44 | } |
| 45 | "secret-shared" => { |
| 46 | result.push(IOStatus::Shared); |
| 47 | } |
| 48 | _ => { |
| 49 | return Err(runtime_error!("Invalid token: {}", token)); |
| 50 | } |
| 51 | } |
| 52 | } |
| 53 | Ok(result) |
| 54 | } |
| 55 | |
| 56 | #[derive(Parser, Debug)] |
| 57 | #[clap(author, version, about, long_about=None)] |