Module Base64_rfc2045
Decode
type src
=[
|
`Manual
|
`Channel of Stdlib.in_channel
|
`String of string
]
The type for input sources. With a
`Manual
source the client must provide input withsrc
.
val src : decoder -> Stdlib.Bytes.t -> int -> int -> unit
src d s j l
providesd
withl
bytes to read, starting atj
ins
. This byte range is read by calls todecode
withd
until`Await
is returned. To signal the end of input, call the function withl = 0
.
val decode : decoder -> decode
decode d
is:`Await
ifd
has a`Manual
input source and awaits for more input. The client must usesrc
to provide it.`End
if the end of input was reached`Malformed bytes
if thebytes
sequence is malformed according to the decoded base64 encoding scheme. If you are interested in a best-effort decoding, you can still continue to decode after an error until the decode synchronizes again on valid bytes.`Flush data
if adata
sequence value was decoded.`Wrong_padding
if decoder retrieve a wrong padding at the end of the input.
Note. Repeated invocation always eventually returns
`End
, even in case of errors.
val decoder_byte_count : decoder -> int
decoder_byte_count d
is the number of characters already decoded ond
(included malformed ones). This is the lastdecode
's end output offset counting from beginning of the stream.
val decoder_dangerous : decoder -> bool
decoder_dangerous d
returnstrue
if encoded input does not respect the 80-columns rule. If your are interested in a best-effort decoding you can still continue to decode even ifdecoder_dangerous d
returnstrue
. Nothing grow automatically internally in this state.
type dst
=[
|
`Channel of Stdlib.out_channel
|
`Buffer of Stdlib.Buffer.t
|
`Manual
]
The type for output destinations. With a
`Manual
destination the client must provide output storage withdst
.
val encode : encoder -> encode -> [ `Ok | `Partial ]
encode e v
: is`Partial
iffe
has a`Manual
destination and needs more output storage. The client must usedst
to provide a new buffer and then callencode
with`Await
until`Ok
is returned.`Ok
when the encoder is ready to encode a new`Char
or`End
For
`Manual
destination, encoding`End
always return`Partial
, the client should continue as usual with`Await
until`Ok
is returned at which pointdst_rem
encoder
is guaranteed to be the size of the last provided buffer (i.e. nothing was written).Raises.
Invalid_argument
if a`Char
or`End
is encoded after a`Partial
encode.