pruned unstable/bytes (moved some code back to web-server)

Corrected contracts from serializable? to printable/c.
This commit is contained in:
Ryan Culpepper 2011-12-18 00:04:05 -07:00
parent dd061bdb17
commit bf21e5b765
3 changed files with 19 additions and 20 deletions

View File

@ -1,19 +1,9 @@
#lang racket/base #lang racket/base
(require racket/contract/base (require racket/contract/base)
racket/serialize)
(provide/contract (provide/contract
[read/bytes (bytes? . -> . serializable?)] [read/bytes (bytes? . -> . printable/c)]
[write/bytes (serializable? . -> . bytes?)] [write/bytes (printable/c . -> . bytes?)])
[bytes-ci=? (bytes? bytes? . -> . boolean?)])
(define (bytes-ci=? b0 b1)
(string-ci=? (bytes->string/utf-8 b0)
(bytes->string/utf-8 b1)))
;; Eli: If this ever gets in, it should say that the memory requirements
;; are 4 times the input size, especially since bytes are often used to save
;; space. Also, fails on (bytes-ci=? #"\277" #"\277"), and a trivial fix
;; would still fail on (bytes-ci=? #"\276\277" #"\277\276")
(define (read/bytes bs) (define (read/bytes bs)
(read (open-input-bytes bs))) (read (open-input-bytes bs)))

View File

@ -1,6 +1,6 @@
#lang scribble/doc #lang scribble/doc
@(require scribble/base scribble/manual "utils.rkt" @(require scribble/base scribble/manual "utils.rkt"
(for-label racket/base unstable/bytes racket/serialize (for-label racket/base unstable/bytes
racket/contract)) racket/contract))
@title[#:tag "bytes"]{Bytes} @title[#:tag "bytes"]{Bytes}
@ -9,16 +9,12 @@
@unstable-header[] @unstable-header[]
@defproc[(bytes-ci=? [b1 bytes?] [b2 bytes?]) boolean?]{
Compares two bytes case insensitively.
}
@defproc[(read/bytes [b bytes?]) @defproc[(read/bytes [b bytes?])
serializable?]{ printable/c]{
@racket[read]s a value from @racket[b] and returns it. @racket[read]s a value from @racket[b] and returns it.
} }
@defproc[(write/bytes [v serializable?]) @defproc[(write/bytes [v printable/c])
bytes?]{ bytes?]{
@racket[write]s @racket[v] to a bytes and returns it. @racket[write]s @racket[v] to a bytes and returns it.
} }

View File

@ -16,6 +16,19 @@
;; -- ;; --
(define (bytes-ci=? b0 b1)
(string-ci=? (bytes->string/utf-8 b0)
(bytes->string/utf-8 b1)))
;; Eli: If this ever gets in, it should say that the memory requirements
;; are 4 times the input size, especially since bytes are often used to save
;; space. Also, fails on (bytes-ci=? #"\277" #"\277"), and a trivial fix
;; would still fail on (bytes-ci=? #"\276\277" #"\277\276")
(provide/contract
[bytes-ci=? (bytes? bytes? . -> . boolean?)])
;; --
;; network-error: symbol string . values -> void ;; network-error: symbol string . values -> void
;; throws a formatted exn:fail:network ;; throws a formatted exn:fail:network
(define (network-error src fmt . args) (define (network-error src fmt . args)