Skip to content

Releases: twitter/bijection

"Bridging the Future Gap"

03 Jul 23:04
Compare
Choose a tag to compare

Injection.invert returns Try

Ever wonder why you could not invert a value? We now support encoding some failure information using Try.

The injection trait becomes approximately:

trait Injection[A, B] extends Serializable { self =>
  def apply(a: A): B
  def invert(b: B): Try[A]
}

This means we dropped support for 2.9.2 and publish for 2.9.3 and 2.10. This was work by @softprops in #120

Future/Try Bijections

Many users have existing code using Twitter Futures and Twitter Trys and want to easily interoperate with less boilerplate. @mosesn contributed #121 to do just that. Use:

https://github.com/twitter/bijection/blob/develop/bijection-util/src/main/scala/com/twitter/bijection/twitter_util/UtilBijections.scala#L39

In the bijection-util jar.

Injection and Bijection no longer subclass Function

For the typeclass pattern we use, we need to be able to make injection and bijection objects implicitly available, but if they subclass function that makes them implicit conversions in Scala's eyes: not what we intended. We added an implicit conversion to function, so any old source should work as long as it was not using this unintended "feature".

Codec[T] type alias for Injection[T, Array[Bytes]]

We often use Injections for serialization. This makes that code a bit more readable. The alias is in the package object.

Issues Closed

  • Either Injections: #120
  • Bijection from BigInt -> BigInteger: #122
  • copy base64 impl, remove commons-codec dep: #123
  • bijection/injection no longer extend fn: #124
  • Bijection between scala/twitter future & try: #121
  • Add Codec type alias: #118
  • Remove call-by-name on future and try in bijection-util: #114
  • Fix TBinaryProtocol bug in bijection-scrooge: #117
  • Add OSGi Metadata to all jars: #113

###Contributors