diff --git a/src/base64/decoder.jl b/src/base64/decoder.jl index 006dab8..6046e7f 100644 --- a/src/base64/decoder.jl +++ b/src/base64/decoder.jl @@ -41,6 +41,14 @@ function Base64DecoderStream(stream::IO; kwargs...) return TranscodingStream(Base64Decoder(;kwargs...), stream) end +function TranscodingStreams.minoutsize(::Base64Decoder, ::Memory) + return 3 +end + +function TranscodingStreams.expectedsize(::Base64Decoder, input::Memory) + return cld(input.size, 4) * 3 + 3 +end + function TranscodingStreams.startproc( codec :: Base64Decoder, state :: Symbol, diff --git a/src/base64/encoder.jl b/src/base64/encoder.jl index f122cb2..212c771 100644 --- a/src/base64/encoder.jl +++ b/src/base64/encoder.jl @@ -38,6 +38,14 @@ function Base64EncoderStream(stream::IO; kwargs...) return TranscodingStream(Base64Encoder(;kwargs...), stream) end +function TranscodingStreams.minoutsize(::Base64Encoder, ::Memory) + return 4 +end + +function TranscodingStreams.expectedsize(::Base64Encoder, input::Memory) + return cld(input.size, 3) * 4 + 4 +end + function TranscodingStreams.startproc( codec :: Base64Encoder, state :: Symbol, @@ -61,6 +69,7 @@ function TranscodingStreams.process( error[] = ArgumentError("encoding is already finished") return 0, 0, :error elseif output.size < 4 + @assert false # Need more output space. return 0, 0, :ok end