Enumerationswift-nio 2.72.0NIOEmbedded
LeftOverState
LeftOverState
represents any left-over inbound, outbound, and pending outbound events that hit the EmbeddedChannel
and were not consumed when finish
was called on the EmbeddedChannel
.
enum LeftOverState
EmbeddedChannel
is most useful in testing and usually in unit tests, you want to consume all inbound and outbound data to verify they are what you expect. Therefore, when you finish
an EmbeddedChannel
it will return if it’s either .clean
(no left overs) or that it has .leftOvers
.
Cases
case clean
The
EmbeddedChannel
is clean, ie. no inbound, outbound, or pending outbound data left onfinish
.case leftOvers(inbound: [NIOAny], outbound: [NIOAny], pendingOutbound: [NIOAny])
The
EmbeddedChannel
has inbound, outbound, or pending outbound data left onfinish
.
Other members in extension
View members
Hide members
This section is hidden by default because it contains too many (29) members.
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.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.
init(handlers: [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
.
Show implementation details (1)
Hide implementation details
Citizens in NIOEmbedded
Instance members
var hasLeftOvers: Bool
true
if theEmbeddedChannel
if there was unconsumed inbound, outbound, or pending outbound data left on theChannel
when it wasfinish
ed.var isClean: Bool
true
if theEmbeddedChannel
wasclean
onfinish
, ie. there is no unconsumed inbound, outbound, or pending outbound data left on theChannel
.