-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
stdlib : base64 encode to writer #20961
Conversation
750cfea
to
db0c706
Compare
This is a useful addition, thank you! Ideally, a reader interface would also be great, but this is much more complicated. |
If i'm motivated i'll take a look into it. I think if we base ourserves on Reader's |
I realize i removed the comptime keyword on a test that was explicitely comptime. I should try to find a way to avoid this. |
There, using BoundedArray the tests works at comptime, while still showing that it uses Writer's writeAll. |
b326483
to
f9196eb
Compare
So i looked into it for a bit, and it's actually not that hard. The This means in theory that you could encode a file directly to base64 without having to load it in memory. Sounds pretty nice ! |
while i'm at it, should i try to do the reverse for decoding ? |
That could be great, if only for consistency. But in a distinct PR. |
Is there anything missing for this PR @jedisct1 ? Not trying to stress you on the matter, genuinely asking, as I do not know if there are any other prerequisites. Thank you for your feedback. |
ab740ca
to
ffc5b08
Compare
@marler8997 i applied your suggestions to the other method in b9dfe0f |
b9dfe0f
to
51c2b14
Compare
Now with a |
Hey there. Anything missing here so it can be merged? I'm planning on doing the decoding part soon in another PR. |
Co-authored-by: Jonathan Marler <[email protected]>
Head branch was pushed to by a user without write access
51c2b14
to
bcf4d78
Compare
thanks @Vexu for the auto-merge. Could you reenable it? I just rebased again. There was an error in aarch-linux-release, but it wasn't related to my stuff. |
Hello,
The current base64 interface only allows encoding to slices, making it impractical (although not impossible) to use when encoding dynamically to a document (such as a json string, as an example).
This PR adds the
encodeWriter
API toBase64Encoder
, relying on the destination having thewriteAll
interface ofWriter
. As it is possible to encode base64 data by chunks of 3 bytes, it progressively encodes the source data in the stream without unnecessary heap allocations.