XOR-URL Rust type best practice

What data type does the dev team use internally to represent XOR-URLs ala safe://hnyynyztg1aykw1k4kfiqi1tomhnojwfutzhfynaz8izr6bchzgoeoku41bnc? https://github.com/servo/rust-url or perhaps something more specific?

2 Likes

Yes, we use that crate at the moment, this is where we currently have the parsing code: https://github.com/maidsafe/safe-api/blob/master/safe-api/src/api/helpers.rs#L169

1 Like

@bochaco

It may be useful to alias or reimplement a specific XOR-URL type and add it and its suite of functions to https://github.com/maidsafe/safe-nd.

XOR-URL values come in three formats once encoded:

  • Base32z
  • Base32
  • Base64

Internally, the datatype uses the XorName struct defined in the safe-nd data types library and has the following structure:

  • An array containing 32 unsigned 8-bit integers.
2 Likes

In addition to what @Shane explained, so far XOR URLs are only known by the client, it’s just a way of encoding the xorname, type tag, etc. Eventually this could be used for lower layers and/or even in routing/vault, if that happens then that’s when it will likely need to be moved to safe-nd, safe-nd is a place for common things across network components, or at least that’s how it was born IIRC.