You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
19 lines
544 B
Racket
19 lines
544 B
Racket
8 years ago
|
#lang restructure/racket
|
||
|
(provide (all-defined-out))
|
||
|
|
||
|
#| approximates
|
||
|
https://github.com/mbutterick/restructure/blob/master/src/EncodeStream.coffee
|
||
|
|#
|
||
|
|
||
|
;; basically just a wrapper for a Racket outputport
|
||
|
(define-subclass object% (REncodeStream [bufferSize 65536])
|
||
|
(field [_port (open-output-bytes)])
|
||
|
(getter-field [pos (port-position _port)])
|
||
|
|
||
|
(define/public (dump)
|
||
|
(get-output-bytes _port))
|
||
|
|
||
|
(define/public (write val)
|
||
|
(cond
|
||
|
[(bytes? val) (write-bytes val _port)]
|
||
|
[else (error 'REncodeStream:write:unknown-type)])))
|