func getData(at: Int, length: Int) -> Data?
Return length
bytes starting at index
and return the result as Data
. This will not change the reader index. The selected bytes must be readable or else nil
will be returned.
func getData(at: Int, length: Int, byteTransferStrategy: ByteTransferStrategy) -> Data?
Return length
bytes starting at index
and return the result as Data
. This will not change the reader index. The selected bytes must be readable or else nil
will be returned.
func getJSONDecodable<T>(T.Type, decoder: JSONDecoder, at: Int, length: Int) throws -> T?
Attempts to decode the length
bytes from index
using the JSONDecoder
decoder
as T
.
func getString(at: Int, length: Int, encoding: String.Encoding) -> String?
Get a String
decoding length
bytes starting at index
with encoding
. This will not change the reader index. The selected bytes must be readable or else nil
will be returned.
func getUUIDBytes(at: Int) -> UUID?
Get a UUID
from the 16 bytes starting at index
. This will not change the reader index. If there are less than 16 bytes starting at index
then nil
will be returned.
func readData(length: Int) -> Data?
Read length
bytes off this ByteBuffer
, move the reader index forward by length
bytes and return the result as Data
.
func readData(length: Int, byteTransferStrategy: ByteTransferStrategy) -> Data?
Read length
bytes off this ByteBuffer
, move the reader index forward by length
bytes and return the result as Data
.
func readJSONDecodable<T>(T.Type, decoder: JSONDecoder, length: Int) throws -> T?
Reads length
bytes from this ByteBuffer
and then attempts to decode them using the JSONDecoder
decoder
.
func readString(length: Int, encoding: String.Encoding) -> String?
Read a String
decoding length
bytes with encoding
from the readerIndex
, moving the readerIndex
appropriately.
func readUUIDBytes() -> UUID?
Read a UUID
from the first 16 bytes in the buffer. Advances the reader index.
func setData<D>(D, at: Int) -> Int
Write the bytes of data
into this ByteBuffer
at index
. Does not move the writer index.
func setJSONEncodable<T>(T, encoder: JSONEncoder, at: Int) throws -> Int
Encodes value
using the JSONEncoder
encoder
and set the resulting bytes into this ByteBuffer
at the given index
.
func setString(String, encoding: String.Encoding, at: Int) throws -> Int
Write string
into this ByteBuffer
at index
using the encoding encoding
. Does not move the writer index.
func setUUIDBytes(UUID, at: Int) -> Int
Set the bytes of the UUID
into this ByteBuffer
at index
, allocating more storage if necessary. Does not move the writer index.
func writeContiguousBytes<Bytes>(Bytes) -> Int
Write bytes
into this ByteBuffer
at the writer index, moving the writer index forward appropriately.
func writeData<D>(D) -> Int
Write the bytes of data
into this ByteBuffer
at the writer index, moving the writer index forward appropriately.
func writeJSONEncodable<T>(T, encoder: JSONEncoder) throws -> Int
Encodes value
using the JSONEncoder
encoder
and writes the resulting bytes into this ByteBuffer
.
func writeString(String, encoding: String.Encoding) throws -> Int
Write string
into this ByteBuffer
using the encoding encoding
, moving the writer index forward appropriately.
func writeUUIDBytes(UUID) -> Int
Write a UUID
info the buffer and advances the writer index.