mirror of
https://github.com/digital-asset/daml.git
synced 2024-09-19 16:57:40 +03:00
ledger-offset: Add a conversion to ByteString. (#11491)
* ledger-offset: Add a conversion to ByteString. I seem to be doing this a lot. CHANGELOG_BEGIN CHANGELOG_END * ledger-offset: Add a conversion from ByteString.
This commit is contained in:
parent
8a9f15b8de
commit
bda35ca234
@ -7,6 +7,7 @@ import java.io.InputStream
|
||||
|
||||
import com.daml.lf.data.{Bytes, Ref}
|
||||
import com.daml.logging.entries.{LoggingValue, ToLoggingValue}
|
||||
import com.google.protobuf.ByteString
|
||||
|
||||
/** Offsets into streams with hierarchical addressing.
|
||||
*
|
||||
@ -25,6 +26,8 @@ final case class Offset(bytes: Bytes) extends Ordered[Offset] {
|
||||
override def compare(that: Offset): Int =
|
||||
Bytes.ordering.compare(this.bytes, that.bytes)
|
||||
|
||||
def toByteString: ByteString = bytes.toByteString
|
||||
|
||||
def toByteArray: Array[Byte] = bytes.toByteArray
|
||||
|
||||
def toInputStream: InputStream = bytes.toInputStream
|
||||
@ -33,7 +36,9 @@ final case class Offset(bytes: Bytes) extends Ordered[Offset] {
|
||||
}
|
||||
|
||||
object Offset {
|
||||
val beforeBegin: Offset = Offset.fromByteArray(Array.empty[Byte])
|
||||
val beforeBegin: Offset = new Offset(Bytes.Empty)
|
||||
|
||||
def fromByteString(bytes: ByteString) = new Offset(Bytes.fromByteString(bytes))
|
||||
|
||||
def fromByteArray(bytes: Array[Byte]) = new Offset(Bytes.fromByteArray(bytes))
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user