Skip to content
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

base64 text pipe #1587

Closed
ChristopherDavenport opened this issue Sep 6, 2019 · 5 comments
Closed

base64 text pipe #1587

ChristopherDavenport opened this issue Sep 6, 2019 · 5 comments

Comments

@ChristopherDavenport
Copy link
Member

I was interested recently in a large file contents and translating it from its base64 to the string representation.

I think it would be fairly straightforward to implement but wanted to see if there was an interest.

@mpilquist
Copy link
Member

I'd love to be able to reuse the methods on ByteVector for this -- perhaps with some small changes to scodec-bits to handle carry?

@mpilquist
Copy link
Member

mpilquist commented Jan 15, 2020

@ChristopherDavenport How are these signatures for the fs2.text object?

object text {

  def base64Decode[F[_]]: Pipe[F, String, Byte] =
    _.through(base64DecodeC).flatMap(Stream.chunk)

  def base64DecodeC[F[_]]: Pipe[F, String, Chunk[Byte]] = ??? 

  def base64Encode[F[_]]: Pipe[F, Byte, String] =
    _.chunks.through(base64EncodeC)

  def base64EncodeC[F[_]]: Pipe[F, Chunk[Byte], String] = ???
}

I think we can skip the chunk variants assuming they stay identities.

@djspiewak
Copy link
Member

Is there a reason to have the separate chunk variants at all rather than just ensuring that the primary variants operate on chunks rather than individual bytes?

@mpilquist
Copy link
Member

@djspiewak I think we can skip the chunk variants. I looked up why we have the utf8 chunk variants and found this: #609

@djspiewak
Copy link
Member

djspiewak commented Jan 15, 2020

Ah interesting. It's worth noting that it would probably be more efficient, even in the utf8 codecs, to exploit the chunkiness more explicitly. But, given that it's Strings, I'm guessing it wouldn't make a massive difference. It would definitely be much more noticeable with Chunk[Byte].

Either way, we definitely don't need the Cs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants