ByteReader
public protocol ByteReader : AnyObject
A type that contains functions for reading Data byte-by-byte.
-
Size of the
data(in bytes).Declaration
Swift
var size: Int { get } -
Data which is being read.
Declaration
Swift
var data: Data { get } -
Offset to a byte in the
datawhich will be read next.Declaration
Swift
var offset: Int { get set } -
Creates an instance for reading bytes from the
data.Declaration
Swift
init(data: Data) -
Reads a byte and returns it, advancing by one position.
Declaration
Swift
func byte() -> UInt8 -
Reads
countbytes and returns them as a[UInt8]array, advancing bycountpositions.Declaration
Swift
func bytes(count: Int) -> [UInt8] -
int(fromBytes:Default implementation) Reads
fromBytesbytes and returns them as aIntnumber, advancing byfromBytespositions.Default Implementation
Reads
fromBytesbytes by either usinguint64(fromBytes:)oruint32(fromBytes:)depending on the platform’s integer bit width, converts the result toInt, and returns it, advancing byfromBytespositions.Declaration
Swift
func int(fromBytes count: Int) -> Int -
Reads
fromBytesbytes and returns them as aUInt64number, advancing byfromBytespositions.Declaration
Swift
func uint64(fromBytes count: Int) -> UInt64 -
Reads
fromBytesbytes and returns them as aUInt32number, advancing byfromBytespositions.Declaration
Swift
func uint32(fromBytes count: Int) -> UInt32 -
Reads
fromBytesbytes and returns them as aUInt16number, advancing byfromBytespositions.Declaration
Swift
func uint16(fromBytes count: Int) -> UInt16 -
init(_:Extension method) Declaration
Swift
public init(_ bitReader: BitReader) -
bytesLeftExtension methodAmount of bytes left to read.
Declaration
Swift
public var bytesLeft: Int { get } -
bytesReadExtension methodAmount of bytes that were already read.
Declaration
Swift
public var bytesRead: Int { get } -
isFinishedExtension method
View on GitHub
ByteReader Protocol Reference