33 releases (stable)

5.0.0 Aug 5, 2022
4.1.0 Aug 4, 2022
4.0.1 Mar 18, 2022
3.1.0 Aug 26, 2021
0.0.1 Dec 5, 2015

#201 in Data structures

Download history 2543/week @ 2024-07-25 2065/week @ 2024-08-01 1324/week @ 2024-08-08 1916/week @ 2024-08-15 1459/week @ 2024-08-22 1903/week @ 2024-08-29 2454/week @ 2024-09-05 2183/week @ 2024-09-12 2099/week @ 2024-09-19 3207/week @ 2024-09-26 2627/week @ 2024-10-03 2868/week @ 2024-10-10 3932/week @ 2024-10-17 4509/week @ 2024-10-24 2762/week @ 2024-10-31 3507/week @ 2024-11-07

15,448 downloads per month
Used in 42 crates (29 directly)

MIT OR BSD-3-Clause

48KB
1K SLoC

xor_name

XorName is an array that is useful for calculations in DHT

MaidSafe website SAFE Network Forum

Serialization

XorName and Prefix are serialized into a human-readable hex string, instead of as a u8 array. This is enabled by default, with the serialize-hex feature. This also allows for these structures to be serialised when used as a key in a map like HashMap, because most formats only allow keys to be strings, instead of more complex types.

A struct like this:

#[derive(Serialize, Deserialize)]
struct MyStruct {
    prefix: Prefix,
    xor_name: XorName,
}

Will yield this JSON

{
  "prefix": "10001101110001111100101000111001101101111101111010011001",
  "xor_name": "8dc7ca39b7de990eb943fd64854776dd85aa82c33a4269693c57b36e0749ed8f"
}

instead of

{
    "prefix": {
        "bit_count": 56,
        "name": [141,199,202,57,183,222,153,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]
    },
    "xor_name": [141,199,202,57,183,222,153,14,185,67,253,100,133,71,118,221,133,170,130,195,58,66,105,105,60,87,179,110,7,73,237,143]
}

License

This SAFE Network library is dual-licensed under the Modified BSD (LICENSE-BSD https://opensource.org/licenses/BSD-3-Clause) or the MIT license (LICENSE-MIT https://opensource.org/licenses/MIT) at your option.

Contributing

Want to contribute? Great 🎉

There are many ways to give back to the project, whether it be writing new code, fixing bugs, or just reporting errors. All forms of contributions are encouraged!

For instructions on how to contribute, see our Guide to contributing.

Dependencies

~1.5–2.5MB
~46K SLoC