Required Instance Methodswift-nio 2.74.0NIOCore
writeInteger(_:to:)
Write an integer to a buffer. Move the writer index to after the written integer.
ByteBuffer-binaryEncodedLengthPrefix.swift:36func writeInteger<IntegerType>(_ integer: IntegerType, to buffer: inout ByteBuffer) -> Int where IntegerType : FixedWidthInteger
Parameters
Returns
The number of bytes used to write the integer.
Other requirements
Instance members
var requiredBytesHint: Int
An estimate of the number of bytes required to write integers using this strategy. Callers may use this to reserve bytes before writing the integer. If the actual bytes used by the write function is more or less than this, it may be necessary to shuffle bytes. Therefore, an accurate prediction here will improve performance. This function will be called from
writeLengthPrefixed(strategy:writeData:)
func readInteger<IntegerType>(as: IntegerType.Type, from: inout ByteBuffer
) -> IntegerType? Read an integer from a buffer. If there are not enough bytes to read an integer of this encoding, return nil, and do not move the reader index. If the the full integer can be read, move the reader index to after the integer, and return the integer.
func writeInteger(Int, reservedCapacity: Int, to: inout ByteBuffer
) -> Int Write an integer to a buffer. Move the writer index to after the written integer. This function will be called when an integer needs to be written, and some capacity has already been reserved for it. Implementers should consider using a less efficient encoding, if possible, to fit exactly within the reserved capacity. Otherwise, the caller will need to shift bytes to reconcile the difference. It is up to the implementer to find the balance between performance and size.