ByteBufferAllocator
The preferred allocator for ByteBuffer
values. The allocation strategy is opaque but is currently libc’s malloc
, realloc
and free
.
struct ByteBufferAllocator
The preferred allocator for ByteBuffer
values. The allocation strategy is opaque but is currently libc’s malloc
, realloc
and free
.
struct ByteBufferAllocator
import NIOCore
The core abstractions that make up SwiftNIO.
struct ByteBuffer
ByteBuffer
stores contiguously allocated raw bytes. It is a random and sequential accessible sequence of zero or more bytes (octets).
struct ByteBufferView
A view into a portion of a ByteBuffer
.
enum Endianness
Endianness refers to the sequential order in which bytes are arranged into larger numerical values when stored in memory or when transmitted over digital links.
final class NIOFileHandle
Deprecated. NIOFileHandle
is a handle to an open file descriptor.
protocol FileDescriptor
struct FileRegion
A FileRegion
represent a readable portion usually created to be sent over the network.
typealias NIOPOSIXFileMode = mode_t
enum IOData
IOData
unifies standard SwiftNIO types that are raw bytes of data; currently ByteBuffer
and FileRegion
.
protocol Sendable
init()
Create a fresh ByteBufferAllocator
. In the future the allocator might use for example allocation pools and therefore it’s recommended to reuse ByteBufferAllocators
where possible instead of creating fresh ones in many places.
func buffer(buffer: ByteBuffer) -> ByteBuffer
Create a fresh ByteBuffer
containing the readable bytes of buffer
.
func buffer<Bytes>(bytes: Bytes) -> ByteBuffer where Bytes : Sequence, Bytes.Element == UInt8
Create a fresh ByteBuffer
containing the bytes
.
func buffer(capacity: Int) -> ByteBuffer
Request a freshly allocated ByteBuffer
of size capacity
or larger.
func buffer(dispatchData: DispatchData) -> ByteBuffer
Create a fresh ByteBuffer
containing the bytes contained in the given DispatchData
.
func buffer<I>(integer: I, endianness: Endianness = .big, as: I.Type = I.self) -> ByteBuffer where I : FixedWidthInteger
Create a fresh ByteBuffer
containing the bytes of the byte representation in the given endianness
of integer
.
func buffer(plainHexEncodedBytes string: String) throws -> ByteBuffer
Create a fresh ByteBuffer
containing the bytes
decoded from the ASCII plainHexEncodedBytes
string .
func buffer(repeating byte: UInt8, count: Int) -> ByteBuffer
Create a fresh ByteBuffer
containing count
repetitions of byte
.
func buffer(staticString string: StaticString) -> ByteBuffer
Create a fresh ByteBuffer
containing the bytes of the string
encoded as UTF-8.
func buffer(string: String) -> ByteBuffer
Create a fresh ByteBuffer
containing the bytes of the string
encoded as UTF-8.
func buffer(substring string: Substring) -> ByteBuffer
Create a fresh ByteBuffer
containing the bytes of the string
encoded as UTF-8.
import NIOFoundationCompat
func buffer(data: Data) -> ByteBuffer
Create a fresh ByteBuffer
containing the bytes contained in the given Data
.