blob: 52ca396ade652dc0cd03fdbf0eb5546aefa59e03 [file] [log] [blame]
Austin Schuh272c6132020-11-14 16:37:52 -08001import Foundation
2
3/// FlatbufferObject structures all the Flatbuffers objects
4public protocol FlatBufferObject {
5 var __buffer: ByteBuffer! { get }
6 init(_ bb: ByteBuffer, o: Int32)
7}
8
9public protocol ObjectAPI {
10 associatedtype T
11 static func pack(_ builder: inout FlatBufferBuilder, obj: inout T) -> Offset<UOffset>
12 mutating func unpack() -> T
13}
14
15/// Readable is structures all the Flatbuffers structs
16///
17/// Readable is a procotol that each Flatbuffer struct should confirm to since
18/// FlatBufferBuilder would require a Type to both create(struct:) and createVector(structs:) functions
19public protocol Readable: FlatBufferObject {
20 static var size: Int { get }
21 static var alignment: Int { get }
22}
23
24public protocol Enum {
25 associatedtype T: Scalar
26 static var byteSize: Int { get }
27 var value: T { get }
28}