MCPcopy Create free account
hub / github.com/ciphermodelabs/ciphercore / get_tokens

Function get_tokens

ciphercore-base/src/bin/ciphercore_split_parties.rs:24–54  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

22///
23/// Vector of party identifiers
24fn 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)]

Callers 1

mainFunction · 0.70

Calls 2

is_emptyMethod · 0.80
pushMethod · 0.45

Tested by

no test coverage detected