mirror of https://github.com/sbt/sbt.git
Remove InputStream/OutputStream support
This commit is contained in:
parent
ab9165ab04
commit
bcd5e800c4
|
|
@ -5,8 +5,6 @@ import sbt.internal.util.Types.:+:
|
|||
import sjsonnew.{ Builder, deserializationError, JsonFormat, Unbuilder }
|
||||
import sjsonnew.BasicJsonProtocol, BasicJsonProtocol.asSingleton
|
||||
|
||||
import java.io.{ ByteArrayInputStream, ByteArrayOutputStream, InputStream, OutputStream }
|
||||
|
||||
trait HListFormat {
|
||||
implicit def HConsFormat[H: JsonFormat, T <: HList: JsonFormat]: JsonFormat[H :+: T] =
|
||||
new JsonFormat[H :+: T] {
|
||||
|
|
@ -33,21 +31,4 @@ trait HListFormat {
|
|||
}
|
||||
|
||||
implicit val HNilFormat: JsonFormat[HNil] = asSingleton(HNil)
|
||||
|
||||
}
|
||||
|
||||
trait StreamFormat { self: BasicJsonProtocol =>
|
||||
def streamFormat[T](write: (T, OutputStream) => Unit, read: InputStream => T): JsonFormat[T] = {
|
||||
lazy val byteArrayFormat = implicitly[JsonFormat[Array[Byte]]]
|
||||
val toBytes = (t: T) => { val bos = new ByteArrayOutputStream(); write(t, bos); bos.toByteArray }
|
||||
val fromBytes = (bs: Array[Byte]) => read(new ByteArrayInputStream(bs))
|
||||
|
||||
new JsonFormat[T] {
|
||||
override def read[J](jsOpt: Option[J], unbuilder: Unbuilder[J]): T =
|
||||
fromBytes(byteArrayFormat.read(jsOpt, unbuilder))
|
||||
|
||||
override def write[J](obj: T, builder: Builder[J]): Unit =
|
||||
byteArrayFormat.write(toBytes(obj), builder)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,4 +5,3 @@ import sjsonnew.BasicJsonProtocol
|
|||
object CacheImplicits extends BasicCacheImplicits
|
||||
with BasicJsonProtocol
|
||||
with HListFormat
|
||||
with StreamFormat
|
||||
|
|
|
|||
Loading…
Reference in New Issue