Structureswift-nio 2.72.0NIOCore
FileRegion
A FileRegion
represent a readable portion usually created to be sent over the network.
struct FileRegion
Usually a FileRegion
will allow the underlying transport to use sendfile
to transfer its content and so allows transferring the file content without copying it into user-space at all. If the actual transport implementation really can make use of sendfile or if it will need to copy the content to user-space first and use write
/ writev
is an implementation detail. That said using FileRegion
is the recommended way to transfer file content if possible.
One important note, depending your ChannelPipeline
setup it may not be possible to use a FileRegion
as a ChannelHandler
may need access to the bytes (in a ByteBuffer
) to transform these.
See also
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
.struct ByteBufferAllocator
The preferred allocator for
ByteBuffer
values. The allocation strategy is opaque but is currently libc’smalloc
,realloc
andfree
.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.
class NIOFileHandle
A
NIOFileHandle
is a handle to an open file.protocol FileDescriptor
typealias NIOPOSIXFileMode
enum IOData
IOData
unifies standard SwiftNIO types that are raw bytes of data; currentlyByteBuffer
andFileRegion
.
Citizens in NIOCore
Conformances
protocol CustomStringConvertible
A type with a customized textual representation.
protocol Equatable
A type that can be compared for value equality.
Type members
init(fileHandle: NIOFileHandle
) throws Create a new
FileRegion
forming a complete file.init(fileHandle: NIOFileHandle, readerIndex: Int, endIndex: Int
) Create a new
FileRegion
from an openNIOFileHandle
.static func == (lhs: FileRegion, rhs: FileRegion
) -> Bool
Instance members
var description: String
var endIndex: Int
The end index of this
FileRegion
.let fileHandle: NIOFileHandle
The
NIOFileHandle
that is used by thisFileRegion
.var readableBytes: Int
The number of readable bytes within this FileRegion (taking the
readerIndex
andendIndex
into account).var readerIndex: Int
The current reader index of this
FileRegion
func moveReaderIndex(forwardBy: Int
) Move the readerIndex forward by
offset
.
Type features
static func != (lhs: Self, rhs: Self
) -> Bool Returns a Boolean value indicating whether two values are not equal.