Initializerswift-nio 2.72.0NIOEmbedded
init(handlers:loop:)
Create a new instance.
Embedded.swift:820init(handlers: [ChannelHandler], loop: EmbeddedEventLoop = EmbeddedEventLoop())
Parameters
During creation it will automatically also register itself on the EmbeddedEventLoop
.
Other members in extension
Types
enum BufferState
BufferState
represents the state of either the inbound, or the outboundEmbeddedChannel
buffer. These buffers contain data that travelled theChannelPipeline
all the way.enum LeftOverState
LeftOverState
represents any left-over inbound, outbound, and pending outbound events that hit theEmbeddedChannel
and were not consumed whenfinish
was called on theEmbeddedChannel
.struct SynchronousOptions
struct WrongTypeError
WrongTypeError
is throws if you usereadInbound
orreadOutbound
and request a certain type but the first item in the respective buffer is of a different type.
Type members
init(handler: ChannelHandler?, loop: EmbeddedEventLoop
) Create a new instance.
Instance members
var allocator: ByteBufferAllocator
var allowRemoteHalfClosure: Bool
var closeFuture: EventLoopFuture<Void>
var embeddedEventLoop: EmbeddedEventLoop
Returns the
EmbeddedEventLoop
that thisEmbeddedChannel
uses. This will return the same instance asEmbeddedChannel.eventLoop
but as the concreteEmbeddedEventLoop
rather than asEventLoop
existential.var eventLoop: EventLoop
var isActive: Bool
Returns
true
if theEmbeddedChannel
is ‘active’.var isWritable: Bool
var localAddress: SocketAddress?
let parent: Channel?
nil
becauseEmbeddedChannel
s don’t have parents.var pipeline: ChannelPipeline
var remoteAddress: SocketAddress?
var syncOptions: NIOSynchronousChannelOptions?
func bind(to: SocketAddress, promise: EventLoopPromise<Void>?
) Fires the (outbound)
bind
event through theChannelPipeline
. If the event hits theEmbeddedChannel
which happens when it travels theChannelPipeline
all the way to the front, this will also set theEmbeddedChannel
’slocalAddress
.func connect(to: SocketAddress, promise: EventLoopPromise<Void>?
) Fires the (outbound)
connect
event through theChannelPipeline
. If the event hits theEmbeddedChannel
which happens when it travels theChannelPipeline
all the way to the front, this will also set theEmbeddedChannel
’sremoteAddress
.func finish(
) throws -> LeftOverState Synchronously closes the
EmbeddedChannel
.func finish(acceptAlreadyClosed: Bool
) throws -> LeftOverState Synchronously closes the
EmbeddedChannel
.func getOption<Option>(Option
) -> EventLoopFuture<Option.Value> func readInbound<T>(as: T.Type
) throws -> T? If available, this method reads one element of type
T
out of theEmbeddedChannel
’s inbound buffer. If the first element was of a different type than requested,EmbeddedChannel.WrongTypeError
will be thrown, if there are no elements in the outbound buffer,nil
will be returned.func readOutbound<T>(as: T.Type
) throws -> T? If available, this method reads one element of type
T
out of theEmbeddedChannel
’s outbound buffer. If the first element was of a different type than requested,EmbeddedChannel.WrongTypeError
will be thrown, if there are no elements in the outbound buffer,nil
will be returned.func setOption<Option>(Option, value: Option.Value
) -> EventLoopFuture<Void> func throwIfErrorCaught(
) throws This method will throw the error that is stored in the
EmbeddedChannel
if any.func writeInbound<T>(T
) throws -> BufferState Sends an inbound
channelRead
event followed by achannelReadComplete
event through theChannelPipeline
.func writeOutbound<T>(T
) throws -> BufferState Sends an outbound
writeAndFlush
event through theChannelPipeline
.