Instance Methodswift-nio 2.72.0NIOCore
buffer(integer:endianness:as:)
Create a fresh ByteBuffer
containing the bytes of the byte representation in the given endianness
of integer
.
func buffer<I>(integer: I, endianness: Endianness = .big, as: I.Type = I.self) -> ByteBuffer where I : FixedWidthInteger
Returns
The ByteBuffer
containing the written bytes.
This will allocate a new ByteBuffer
with enough space to fit integer
and potentially some extra space.
Other members in extension
Type members
init(
) Create a fresh
ByteBufferAllocator
. In the future the allocator might use for example allocation pools and therefore it’s recommended to reuseByteBufferAllocators
where possible instead of creating fresh ones in many places.
Instance members
func buffer(buffer: ByteBuffer
) -> ByteBuffer Create a fresh
ByteBuffer
containing the readable bytes ofbuffer
.func buffer<Bytes>(bytes: Bytes
) -> ByteBuffer Create a fresh
ByteBuffer
containing thebytes
.func buffer(capacity: Int
) -> ByteBuffer Request a freshly allocated
ByteBuffer
of sizecapacity
or larger.func buffer(dispatchData: DispatchData
) -> ByteBuffer Create a fresh
ByteBuffer
containing the bytes contained in the givenDispatchData
.func buffer(repeating: UInt8, count: Int
) -> ByteBuffer Create a fresh
ByteBuffer
containingcount
repetitions ofbyte
.func buffer(staticString: StaticString
) -> ByteBuffer Create a fresh
ByteBuffer
containing the bytes of thestring
encoded as UTF-8.func buffer(string: String
) -> ByteBuffer Create a fresh
ByteBuffer
containing the bytes of thestring
encoded as UTF-8.func buffer(substring: Substring
) -> ByteBuffer Create a fresh
ByteBuffer
containing the bytes of thestring
encoded as UTF-8.