Uh oh!
There was an error while loading. Please reload this page.
stdlib : base64 encode to writer - #20961
Conversation
750cfea to
db0c706Comparejedisct1
commented
Aug 6, 2024
This is a useful addition, thank you! Ideally, a reader interface would also be great, but this is much more complicated. |
Arwalk
commented
Aug 6, 2024
If i'm motivated i'll take a look into it. I think if we base ourserves on Reader's |
Arwalk
commented
Aug 6, 2024
I realize i removed the comptime keyword on a test that was explicitely comptime. I should try to find a way to avoid this. |
Arwalk
commented
Aug 6, 2024
There, using BoundedArray the tests works at comptime, while still showing that it uses Writer's writeAll. |
b326483 to
f9196ebCompareArwalk
commented
Aug 8, 2024
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 ! |
Arwalk
commented
Aug 8, 2024
while i'm at it, should i try to do the reverse for decoding ? |
jedisct1
commented
Aug 8, 2024
That could be great, if only for consistency. But in a distinct PR. |
Arwalk
commented
Aug 9, 2024
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
ffc5b08CompareUh oh!
There was an error while loading. Please reload this page.
@marler8997 i applied your suggestions to the other method in b9dfe0f |
b9dfe0f to
51c2b14CompareArwalk
commented
Aug 14, 2024
Now with a |
Arwalk
commented
Aug 29, 2024
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 <johnnymarler@gmail.com>
Head branch was pushed to by a user without write access
51c2b14 to
bcf4d78CompareArwalk
commented
Sep 3, 2024
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
encodeWriterAPI toBase64Encoder, relying on the destination having thewriteAllinterface 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.