1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65

use crate::StellarValue;

pub fn as_str(value: StellarValue) -> Result<String, String> {

    match value {
        StellarValue::Str(res) => Ok(res),
        _ => Err("value is not a string.".to_string())
    }

}

pub fn as_uint8(value: StellarValue) -> Result<u8, String> {

    match value {
        StellarValue::UInt8(res) => Ok(res),
        _ => Err("value is not uint8.".to_string())
    }

}

pub fn as_uint16(value: StellarValue) -> Result<u16, String> {

    match value {
        StellarValue::UInt16(res) => Ok(res),
        _ => Err("value is not uint16.".to_string())
    }

}

pub fn as_uint32(value: StellarValue) -> Result<u32, String> {

    match value {
        StellarValue::UInt32(res) => Ok(res),
        _ => Err("value is not uint32.".to_string())
    }

}

pub fn as_uint64(value: StellarValue) -> Result<u64, String> {

    match value {
        StellarValue::UInt64(res) => Ok(res),
        _ => Err("value is not uint64.".to_string())
    }

}

pub fn as_uint128(value: StellarValue) -> Result<u128, String> {

    match value {
        StellarValue::UInt128(res) => Ok(res),
        _ => Err("value is not uint128.".to_string())
    }

}

pub fn as_bytes(value: StellarValue) -> Result<Vec<u8>, String> {

    match value {
        StellarValue::Bytes(res) => Ok(res),
        _ => Err("value is not bytes.".to_string())
    }

}