Rust Stellar Notation

The Rust Implementation of Stellar Notation, a data encoding library.

Usage

```

stellar-notation = "0.9.9"

```

```

use stellarnotation::{ bytedecode, byteencode, valuedecode, value_encode }

```

Values

Encoding and Decoding Values into Hex String is supported for u128 and bytes.

u128

```

let u128str: String = valueencode::u128(1);

let u128num: u128 = valuedecode::as128(u128str);

```

bytes

```

let bytes: Vec = vec![1,2,3]

let bytestr: String = valueencode::bytes(bytes);

let decodedbytestr: Vec = valuedecode::asbytes(byte_str);

```

Object

An Object is a Key-Value Tuple. Keys and Values are UTF-8 Strings.

Object Encoding

```

let key: String = String::from("key_1");

let value: String = String::from("value_1");

let object: Vec = byte_encode::object(key, value);

```

Object Encoding Structure

| Value | Size(bytes) | |---|---| | Key Length | 1 | | Value Length | 8 | | Key Data | max 255 | | Value Data | max ~18.45 exa |

Value data is also limited by the system file size limit.

Object Decoding

Reconverts bytes into a Two String Tuple.

```

let keyvalue: (String, String) = bytedecode::object(serialized);

```

Groups

Group Encoding

Converts a group of Two String Tuples into bytes.

```

let objects: Vec<(String, String)> = vec![ object1, object2, object3 ]

let group: Vec = byte_encode::group(objects);

```

Group Encoding Structure

| Group | | --- | | Obj1, Obj2 ... Obj(n) |

Group Decoding

Reconverts bytes into a group of two string tuples.

```

let keyvaluegroup: Vec<(String, String)> = byte_decode::group(group);

```

END