bencode: alloe bencode of byte-arrays.
parent
55a69c492a
commit
1adabc3168
|
@ -6,6 +6,8 @@ USING: bencode linked-assocs tools.test ;
|
|||
|
||||
{ "4:spam" } [ "spam" >bencode ] unit-test
|
||||
|
||||
{ "3:\x01\x02\x03" } [ B{ 1 2 3 } >bencode ] unit-test
|
||||
|
||||
{ { "spam" 42 } } [ "l4:spami42ee" bencode> ] unit-test
|
||||
|
||||
{ LH{ { "bar" "spam" } { "foo" 42 } } } [
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
USING: arrays assocs combinators io io.encodings.ascii
|
||||
io.encodings.string io.streams.string kernel linked-assocs math
|
||||
math.parser sequences strings ;
|
||||
USING: arrays assocs byte-arrays combinators io
|
||||
io.streams.string kernel linked-assocs math math.parser
|
||||
sequences strings ;
|
||||
IN: bencode
|
||||
|
||||
GENERIC: >bencode ( obj -- bencode )
|
||||
|
@ -11,6 +11,8 @@ M: integer >bencode
|
|||
M: string >bencode
|
||||
[ length number>string ":" ] keep 3append ;
|
||||
|
||||
M: byte-array >bencode "" like >bencode ;
|
||||
|
||||
M: sequence >bencode
|
||||
[ >bencode ] map concat "l" "e" surround ;
|
||||
|
||||
|
|
Loading…
Reference in New Issue