8.4 Octet Streams
(require rebellion/media/application/octet-stream) | |
package: rebellion |
An octet stream is an immutable byte string whose last byte may include extra bits of padding, making octet streams semantically similar to bitstrings. Octet streams are media, and their media type is application/octet-stream.
procedure
(octet-stream? v) → boolean?
v : any/c
procedure
(application/octet-stream [#:padding padding]) → media-type?
padding : (integer-in 0 7) = 0
> (application/octet-stream) (media-type "application/octet-stream")
> (application/octet-stream #:padding 6) (media-type "application/octet-stream; padding=6")
procedure
(octet-stream bstr [#:padding padding]) → octet-stream?
bstr : immutable-bytes? padding : (integer-in 0 7) = 0
> (octet-stream #"Apple") (octet-stream #"Apple" 0)
> (octet-stream #"Apple" #:padding 3) (octet-stream #"Apple" 3)
procedure
(octet-stream->bitstring octets) → bitstring?
octets : octet-stream?
> (octet-stream->bitstring (octet-stream #"Apple"))
(bitstring
0
1
0
0
0
0
0
1
0
1
1
1
0
0
0
0
0
1
1
1
0
0
0
0
0
1
1
0
1
1
0
0
0
1
1
0
0
1
0
1)
> (octet-stream->bitstring (octet-stream #"Apple" #:padding 3))
(bitstring
0
1
0
0
0
0
0
1
0
1
1
1
0
0
0
0
0
1
1
1
0
0
0
0
0
1
1
0
1
1
0
0
0
1
1
0
0)
procedure
(octet-stream-bytes octets) → immutable-bytes?
octets : octet-stream?
procedure
(octet-stream-padding octets) → (integer-in 0 7)
octets : octet-stream?
procedure
m : media?
procedure
(octet-stream->media octets) → media?
octets : octet-stream?
> (octet-stream->media (octet-stream #"Apple")) (media (media-type "application/octet-stream") #"Apple")
> (octet-stream->media (octet-stream #"Apple" #:padding 3)) (media (media-type "application/octet-stream; padding=3") #"Apple")