]> git.lizzy.rs Git - rust.git/commit
Added functionality to Base64 package
authorSteven Fackler <sfackler@gmail.com>
Sun, 30 Jun 2013 22:08:22 +0000 (18:08 -0400)
committerSteven Fackler <sfackler@gmail.com>
Thu, 4 Jul 2013 02:45:38 +0000 (22:45 -0400)
commit5a8a30f45bed02a33b2e0e11f0d07cda2f569533
tree1a5a9e4cccd0da80b0dc75a050c87b0db275acdf
parent3c0a1621b550936e862585667d8a58f7a2ab72c5
Added functionality to Base64 package

The Base64 package previously had extremely basic functionality. It only
suported the standard encoding character set, didn't support line breaks
and always padded output. This commit makes it significantly more
powerful.

The FromBase64 impl now supports all of the standard variants of Base64.
It ignores newlines,interprets '-' and '_' as well as '+' and '/' and
doesn't require padding. It isn't incredibly pedantic and will
successfully parse strings that are not strictly valid, but I don't
think the extra complexity required to make it accept _only_ valid
strings is worth it.

The ToBase64 trait has been modified such that to_base64 now takes a
base64::Config struct which contains the output format configuration.
This currently includes the selection of character set (standard or
url safe), whether or not to pad and an optional line break width. The
package comes with three static Config structs for the RFC 4648
standard, RFC 4648 url safe and RFC 2045 MIME formats.

The other option for configuring ToBase64 output would be to have one
method with the configuration flags passed and other traits with default
impls for the common cases, but I think that's a little messier.
src/libextra/base64.rs