Closed rikonaka closed 2 years ago
You can convert it using try_from()
with a slice, as noted here: https://docs.rs/dryoc/latest/dryoc/types/struct.StackByteArray.html#impl-TryFrom%3C%26%27a%20%5Bu8%5D%3E-for-StackByteArray%3CLENGTH%3E
Essentially a byte array has a fixed length, whereas Vec
is variable length, so converting a vec into a byte array might fail which is why you can't use .into()
or From
.
For example, try something like this: https://gist.github.com/brndnmtthws/e0cfdf30316036a9d44cb2223d57cc19
If you happen to be using serde, you can just serialize/deserialize the stackbytearray directly instead and save yourself some typing.
Hi guys, my program need a key exchange function, and I see the dryoc doc here.
But I only have a public key from tcp or udp like
[u8]
, so how can I convert the[u8]
toStackByteArray<32_usize>
then I can use it inSession::new_client_with_defaults
?