write(_:promise:)
ChannelPipeline.swift:825func write<T>(_ data: T, promise: EventLoopPromise<Void>?) where T : Sendable
func write<T>(_ data: T, promise: EventLoopPromise<Void>?) where T : Sendable
s7NIOCore15ChannelPipelineC5write_7promiseyx_AA16EventLoopPromiseVyytGSgts8SendableRzlF
What are these?70F3D
import NIOCore
The core abstractions that make up SwiftNIO.
final class ChannelPipeline
A list of ChannelHandler
s that handle or intercept inbound events and outbound operations of a Channel
. ChannelPipeline
implements an advanced form of the Intercepting Filter pattern to give a user full control over how an event is handled and how the ChannelHandler
s in a pipeline interact with each other.
struct EventLoopPromise<Value>
A promise to provide a result later.
typealias Void = ()
The return type of functions that don’t explicitly specify a return type, that is, an empty tuple ()
.
protocol Sendable
init(channel: Channel)
Create ChannelPipeline
for a given Channel
. This method should never be called by the end-user directly: it is only intended for use with custom Channel
implementations. Users should always use channel.pipeline
to access the ChannelPipeline
for a Channel
.
var debugDescription: String { get }
let eventLoop: EventLoop
The EventLoop
that is used by the underlying Channel
.
var syncOperations: SynchronousOperations { get }
Returns a view of operations which can be performed synchronously on this pipeline. All operations must be called on the event loop.
@preconcurrency func addHandler(_ handler: ChannelHandler & Sendable, name: String? = nil, position: ChannelPipeline.Position = .last) -> EventLoopFuture<Void>
Add a ChannelHandler
to the ChannelPipeline
.
@preconcurrency func addHandler(_ handler: ChannelHandler & Sendable, name: String? = nil, position: ChannelPipeline.Position = .last) async throws
@preconcurrency func addHandlers(_ handlers: (ChannelHandler & Sendable)..., position: ChannelPipeline.Position = .last) -> EventLoopFuture<Void>
Adds the provided channel handlers to the pipeline in the order given, taking account of the behaviour of ChannelHandler.add(first:)
.
@preconcurrency func addHandlers(_ handlers: [ChannelHandler & Sendable], position: ChannelPipeline.Position = .last) -> EventLoopFuture<Void>
Adds the provided channel handlers to the pipeline in the order given, taking account of the behaviour of ChannelHandler.add(first:)
.
@preconcurrency func addHandlers(_ handlers: (ChannelHandler & Sendable)..., position: ChannelPipeline.Position = .last) async throws
@preconcurrency func addHandlers(_ handlers: [ChannelHandler & Sendable], position: ChannelPipeline.Position = .last) async throws
func bind(to address: SocketAddress, promise: EventLoopPromise<Void>?)
func close(mode: CloseMode = .all, promise: EventLoopPromise<Void>?)
func connect(to address: SocketAddress, promise: EventLoopPromise<Void>?)
func containsHandler(name: String) -> EventLoopFuture<Void>
Returns if the ChannelHandler
of the given type is contained in the pipeline.
func containsHandler<Handler>(type: Handler.Type) -> EventLoopFuture<Void> where Handler : ChannelHandler
Returns if the ChannelHandler
of the given type is contained in the pipeline.
func context<Handler>(handlerType: Handler.Type) -> EventLoopFuture<ChannelHandlerContext> where Handler : ChannelHandler
Returns the ChannelHandlerContext
that belongs to a ChannelHandler
of the given type.
func context(name: String) -> EventLoopFuture<ChannelHandlerContext>
Returns the ChannelHandlerContext
that belongs to a ChannelHandler
.
func fireChannelActive()
func fireChannelInactive()
func fireChannelRead<T>(_ data: T) where T : Sendable
func fireChannelReadComplete()
func fireChannelRegistered()
func fireChannelUnregistered()
func fireChannelWritabilityChanged()
func fireErrorCaught(_ error: Error)
@preconcurrency func fireUserInboundEventTriggered(_ event: Sendable)
func flush()
func handler<Handler>(type _: Handler.Type) -> EventLoopFuture<Handler> where Handler : ChannelHandler
Returns the first ChannelHandler
of the given type.
func inboundBufferedBytes() -> EventLoopFuture<Int>
Retrieve the total number of bytes buffered for inbound.
func outboundBufferedBytes() -> EventLoopFuture<Int>
Retrieve the total number of bytes buffered for outbound.
func read()
func register(promise: EventLoopPromise<Void>?)
@preconcurrency func removeHandler(_ handler: RemovableChannelHandler & Sendable) -> EventLoopFuture<Void>
Remove a ChannelHandler
from the ChannelPipeline
.
@preconcurrency func removeHandler(_ handler: RemovableChannelHandler & Sendable) async throws
@preconcurrency func removeHandler(_ handler: RemovableChannelHandler & Sendable, promise: EventLoopPromise<Void>?)
Remove a ChannelHandler
from the ChannelPipeline
.
func removeHandler(name: String) -> EventLoopFuture<Void>
Remove a ChannelHandler
from the ChannelPipeline
.
func removeHandler(name: String) async throws
func removeHandler(name: String, promise: EventLoopPromise<Void>?)
Remove a ChannelHandler
from the ChannelPipeline
.
@preconcurrency func triggerUserOutboundEvent(_ event: Sendable, promise: EventLoopPromise<Void>?)
func writeAndFlush<T>(_ data: T, promise: EventLoopPromise<Void>?) where T : Sendable
@preconcurrency enum Position
A Position
within the ChannelPipeline
used to insert handlers into the ChannelPipeline
.
struct SynchronousOperations
A view of a ChannelPipeline
which may be used to invoke synchronous operations.
@preconcurrency func context(handler: ChannelHandler & Sendable) async throws -> ChannelHandlerContext
@preconcurrency func context(handler: ChannelHandler & Sendable) -> EventLoopFuture<ChannelHandlerContext>
Returns the ChannelHandlerContext
that belongs to a ChannelHandler
.
func context<Handler>(handlerType: Handler.Type) async throws -> ChannelHandlerContext where Handler : ChannelHandler
func context(name: String) async throws -> ChannelHandlerContext
func fireChannelRead(_ data: NIOAny)
func removeHandler(context: ChannelHandlerContext) -> EventLoopFuture<Void>
Remove a ChannelHandler
from the ChannelPipeline
.
func removeHandler(context: ChannelHandlerContext) async throws
func removeHandler(context: ChannelHandlerContext, promise: EventLoopPromise<Void>?)
Remove a ChannelHandler
from the ChannelPipeline
.
func write(_ data: NIOAny, promise: EventLoopPromise<Void>?)
func writeAndFlush(_ data: NIOAny, promise: EventLoopPromise<Void>?)