All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.gu.contentapi.client.thrift.ThriftDeserializer.scala Maven / Gradle / Ivy

The newest version!
package com.gu.contentapi.client.thrift

import java.io.ByteArrayInputStream

import com.twitter.scrooge.{ThriftStruct, ThriftStructCodec}
import org.apache.thrift.protocol.TCompactProtocol
import org.apache.thrift.transport.TIOStreamTransport

object ThriftDeserializer {

  def deserialize[T <: ThriftStruct](responseBody: Array[Byte], codec: ThriftStructCodec[T]): T = {
    val bbis = new ByteArrayInputStream(responseBody)
    val transport = new TIOStreamTransport(bbis)
    val protocol = new TCompactProtocol(transport)
    codec.decode(protocol)
  }
}





© 2015 - 2024 Weber Informatics LLC | Privacy Policy