1 Convertible: Data-Conversion Protocol
(require file/convertible) |
The file/convertible library provides a protocol to mediate between providers of data in different possible formats and consumers of the formats. For example, a datatype that implements prop:convertible might be able to convert itself to a GIF or PDF stream, in which case it would produce data for 'gif-bytes or 'pdf-bytes requests.
Any symbol can be used for a conversion request, but the following should be considered standard:
'text —
a string for human-readable text 'gif-bytes —
a byte string containing a GIF image encoding 'png-bytes —
a byte string containing a PNG image encoding 'ps-bytes —
a byte string containing a PostScript document 'eps-bytes —
a byte string containing an Encapsulated PostScript document 'pdf-bytes —
a byte string containing a PDF document 'pdf-bytes+bounds —
a list containing a byte string and four numbers; the byte string contains a PDF document and the four numbers are sizing information for the PDF document, namely the width, height, ascent and descent in that order
(convertible? v) → boolean? |
v : any/c |
(convert v request [default]) | |||||||||||||||
| |||||||||||||||
v : convertible? | |||||||||||||||
request : symbol? | |||||||||||||||
default : any/c = #f |