Scoop API

scoop:scoop.http:0.1.0

src/eventstream/model.scoop

Selected production source · src/eventstream/model.scoop

1package scoop.http
3import scoop.time.Instant
4import scoop.uuid.Uuid as Guid
6/** The fixed AWS EventStream wire header types, with exact integer widths. */
7public enum AwsEventStreamHeaderValue {
8 Bool(val value: Boolean),
9 Int8(val value: Byte),
10 Int16(val value: Short),
11 Int32(val value: Int),
12 Int64(val value: Long),
13 Bytes(val value: Array<Byte>),
14 Text(val value: String),
15 Timestamp(val value: Instant),
16 Uuid(val value: Guid)
19/** One strictly decoded, case-sensitive header name and its typed value. */
20public class AwsEventStreamHeader internal constructor(public val name: String, public val value: AwsEventStreamHeaderValue)
22/** One complete, checksum-verified message; payload interpretation belongs to the caller. */
23public class AwsEventStreamMessage internal constructor(public val headers: Array<AwsEventStreamHeader>, public val payload: Array<Byte>) {
24 public fun header(name: String): AwsEventStreamHeaderValue? {
25 for (header in headers) if (header.name == name) return Some(header.value)
26 return None
27 }
30public enum AwsEventStreamErrorKind { Length, PreludeChecksum, MessageChecksum, Header, UnexpectedEof }
32/** A wire error located at a byte offset within the current message. */
33public class AwsEventStreamException public constructor(public val kind: AwsEventStreamErrorKind, public val offset: Long, message: String)
34 : Exception(Some(message))