mirror of
https://github.com/YGGverse/aquatic.git
synced 2026-03-31 17:55:36 +00:00
aquatic_ws: twenty byte serde: improve comment
This commit is contained in:
parent
7155f493d9
commit
e76b54e697
1 changed files with 6 additions and 2 deletions
|
|
@ -30,8 +30,12 @@ impl<'de> Visitor<'de> for TwentyByteVisitor {
|
||||||
// var infoHash = 'abcd..'; // 40 hexadecimals
|
// var infoHash = 'abcd..'; // 40 hexadecimals
|
||||||
// Buffer.from(infoHash, 'hex').toString('binary');
|
// Buffer.from(infoHash, 'hex').toString('binary');
|
||||||
// ```
|
// ```
|
||||||
// which seemingly produces a UTF16 string with each char having only
|
// As I understand it:
|
||||||
// the "low byte" set. Here, we extract it by casting it to an u8.
|
// - the code above produces a UTF16 string of 20 chars, each having
|
||||||
|
// only the "low byte" set (e.g., numeric value ranges from 0-255)
|
||||||
|
// - serde_json decodes this to string of 20 chars (tested), each in
|
||||||
|
// the aforementioned range (tested), so the bytes can be extracted
|
||||||
|
// by casting each char to u8.
|
||||||
|
|
||||||
let mut arr = [0u8; 20];
|
let mut arr = [0u8; 20];
|
||||||
let mut char_iter = value.chars();
|
let mut char_iter = value.chars();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue