Expand description
Re-exports of types – out of the internal directory and module structure – useful for users of this crate
Macros§
- _define_
processor_ uni_ and_ sender_ channel_ types - For internal use: defines
ProcessorUniType
&SenderChannel
based on the given [Channels] parameter (for use when spawning processors with [MessagingService::spawn_unresponsive_processor()] & [MessagingService::spawn_responsive_processor()].) - multis_
close_ async - Macro to close, atomically-ish, all Multis passed in as parameters
- new_
composite_ socket_ client - Instantiates & allocates resources for a stateful CompositeSocketClient (suitable for the “Composite Protocol Stacking” pattern), ready to have processors added by spawn_client_processor!().
- new_
composite_ socket_ server - Instantiates & allocates resources for a stateful CompositeSocketServer (suitable for the “Composite Protocol Stacking” pattern),
ready to have processors added by [spawn_unresponsive_server_processor!()] or [spawn_responsive_server_processor!()]
and to be later started by CompositeSocketServer::start_multi_protocol()
– using the default “Atomic” channels (see [new_composite_fullsync_server!()] & [new_composite_crossbeam_server!()] for alternatives).
Params: - new_
socket_ client - Instantiates & allocates resources for a stateless CompositeSocketClient (suitable for single protocol communications),
ready to be later started by
start_client_processor!()
. - new_
socket_ server - Instantiates & allocates resources for a stateless CompositeSocketServer (suitable for single protocol communications),
ready to be later started by [
start_unresponsive_server_processor!()
] or [start_responsive_server_processor!()
]. - spawn_
client_ processor - Spawns a processor for a client (previously instantiated by
new_composite_socket_client!()
) that may communicate with the server using multiple protocols / multiple calls to this macro with different parameters – and finally calling CompositeSocketClient::start_multi_protocol() when the “Composite Protocol Stacking” is complete. - spawn_
server_ processor - See CompositeSocketServer::spawn_processor().
- start_
client_ processor - Starts a client (previously instantiated by
new_socket_client!()
) that will communicate with the server using a single protocol – as defined by the givendialog_processor_builder_fn
, a builder ofStream
s as specified in CompositeSocketClient::spawn_processor(). - start_
server_ processor - Starts a server (previously instantiated by new_socket_server!()) that will communicate with clients using a single protocol – as defined by the given
dialog_processor_builder_fn
, a builder of “unresponsive”Stream
s as specified in CompositeSocketServer::spawn_processor().
If you want to follow the “Composite Protocol Stacking” pattern, see the [spawn_composite_server_processor!()] macro instead. - unis_
close_ async - Macro to close, atomically-ish, all Unis passed as parameters
Structs§
- Client
Connection Manager - Abstracts out the TCP/IP intricacies for establishing (and retrying) connections, while still enabling the “Protocol Stack Composition” pattern by accepting existing connections to be provided (instead of opening new ones).
- Composite
Socket Client - Real definition & implementation for our Socket Client, full of generic parameters.
Probably you want to instantiate this structure through the sugared macros new_socket_client!() or new_composite_socket_client!() instead. Generic Parameters: - Composite
Socket Server - Real definition & implementation for our Socket Server, full of generic parameters.
Probably you want to instantiate this structure through the sugared macros new_socket_server!() or new_composite_socket_server!() instead. Generic Parameters: - Connection
Channel - The abstraction for handling server connections – here, the connections are
provided through a
Stream
instead of through the TCP/IP API directly. This enables the “Protocol Stack Composition” pattern, as already existing connections may be also added to theStream
(in addition to fresh incoming ones).
When the end-of-stream is reached (possibly due to a “server shutdown” request), theStream
will returnNone
. - Const
Config - Implements something that could be called the “Zero-Cost Const Configuration Pattern”, that produces a
usize
whose goal is to be the only const parameter of a generic struct (avoiding the alternative of bloating it with several const params).
When using the const “query functions” defined here inif
s, the compiler will have the opportunity to cancel out any unreachable code (zero-cost abstraction).
Some commonly used combinations may be pre-defined in some enum variants, but you may always build unmapped possibilities through [Self::custom()].
Usage examples: - Multi
Multi
is an event handler capable of having several “listeners” – all of which receives all events.
With this struct, it is possible to:- Mutiny
Stream - Special
Stream
implementation to avoid using dynamic dispatching, so to allow the compiler to fully optimize the whole event consumption chain.
The following paths are covered: - OgreArc
- Wrapper type for data providing an atomic reference counter for dropping control, similar to
Arc
, but allowing a custom allocator to be used – BoundedOgreAllocator. providing reference counting similar to Arc - Ogre
Unique - Wrapper type for data that requires a custom Drop to be called (through an BoundedOgreAllocator).
Similar to C++’s
unique_ptr
- Peer
- Represents a reactive channel connected to a remote peer, through which we’re able to send out “local messages” of type
RetryableSenderImpl::LocalMessages
.
the Self::send() method honors whatever retrying config is specified in [RetryableSenderImpl::CONST_CONFIG]. IMPLEMENTATION NOTE: GAT traits (to reduce the number of generic parameters) couldn’t be used here – even after applying this compiler bug workaround https://github.com/rust-lang/rust/issues/102211#issuecomment-1513931928 – the “error: implementation ofstd::marker::Send
is not general enough” bug kept on popping up in user provided closures that called other async functions. - Receiver
Dropped Err - Indicates the receiver end of a channel was dropped, therefore the
element of type
T
couldn’t be sent and is being returned back along with the error indication.
Important: This is an unrecoverable situation, so trying again is futile. - Server
Connection Handler - Abstracts out, from servers, the connection handling so to enable the “Protocol Stack Composition” pattern:
Binds to a network listening interface and port and starts a network event loop for accepting connections, supplying them to an internal ConnectionChannel (while also allowing manually fed connections). - Socket
Connection - A wrapper for a TcpStream – attaching a custom “state” and unique id to it.
This abstraction plays a role in enabling the “Composite Protocol Stacking” design pattern.
IMPLEMENTATION NOTE: The crate::prelude::Peer object still holds a copy of the state – synced elsewhere with us here – in the future, this should be reworked. - Socket
Options - Socket options for the local peer to be set when the connection is established
- Uni
- Contains the producer-side Uni handle used to interact with the
uni
event – for closing the stream, requiring stats, …
Enums§
- Connection
Event - Event issued by Composite Protocol Clients & Servers when connections are made or dropped
- Instruments
- Honors the Zero-Cost Instrumentation Pattern for the [stream_executors]:
Designed to be used as a const generic parameter for Structs, causes the conditional instrumentation code in client structs to be selectively compiled – see the implemented const methods for documentation of each available instrument. - Protocol
Event - Event issued by Composite Protocol Clients & Servers to their Reactive Processors.
The user code may use those events to maintain a list of connected parties, be notified of stop/close/quit requests, init/de-init sessions, etc. Note that thePeer
objects received in those events may be used, at any time, to send messages to the remote party – like “Shutting down. Goodbye”. IMPLEMENTATION NOTE: GAT traits (to reduce the number of generic parameters) couldn’t be used here – even after applying this compiler bug workaround https://github.com/rust-lang/rust/issues/102211#issuecomment-1513931928 – the “error: implementation ofstd::marker::Send
is not general enough” bug kept on popping up in user provided closures that called other async functions. - Retrying
Strategies - Specifies how to behave when communication failures happen
Traits§
- Bounded
Ogre Allocator - Dictates how data slots – in a bounded allocator – should be acquired and returned for future reuse.
A bounded allocator differs from a tradicional allocator (like Box) in these fundamental aspects: - Channel
Common - Defines common abstractions on how [Uni]s receives produced events and delivers them to
Stream
s.
Implementors should also implement one of ChannelProducer or [UniZeroCopyChannel]. NOTE: all async functions are out of the hot path, so theasync_trait
won’t impose performance penalties - Channel
Consumer - Source of events for MutinyStream.
- Channel
Multi - Defines abstractions specific to [Uni] channels
- Channel
Producer - Defines how to send events (to a [Uni] or [Multi]).
- Channel
Uni - Defines abstractions specific to [Uni] channels
- Full
Duplex Multi Channel - A fully fledged
Multi
channel, that has both the producer and consumer parts Also, laverages generic programming by allowing simpler generic parameters: - Full
Duplex UniChannel - Defines a fully fledged
Uni
channel, that has both the producer and consumer parts Also, laverages generic programming by allowing simpler generic parameters: - Generic
Multi - This trait exists to allow simplifying generic declarations of concrete Multi types.
See also [GenericUni].
Usage: - Generic
Uni - This trait exists to allow simplifying generic declarations of concrete Uni types.
See also [GenericMulti].
Usage: - Messaging
Service - Base trait for server and client services functionalities
- Reactive
Messaging Deserializer - Trait that should be implemented by enums that model the “remote messages” to be consumed by a “Responsive Processor” –
“remote messages” may either be messages produced by the remote server or by the remote client (when we are implementing the opposite peer).
This trait, therefore, specifies how todeserialize()
enum variants received by the remote peer (like RON, for textual protocols) - Reactive
Messaging Serializer - Trait that should be implemented by enums that model the “local messages” to be sent to the remote peer –
“local messages” may either be messages generated by the server or by the client, depending on if you’re building a server or client.
This trait, therefore, specifies how to: - Responsive
Stream - The implementor of this trait adds a new functionality to
Stream
s, allowing the yielded items to be sent out to the peer
Functions§
- ron_
deserializer - RON deserializer
- ron_
serializer - RON serializer
Type Aliases§
- Allocator
Atomic Array - Allocator
Full Sync Array - Channel
Multi ArcAtomic - Channel
Multi ArcCrossbeam - Channel
Multi ArcFull Sync - Channel
Multi Mmap Log - Channel
Multi Ogre ArcAtomic - Channel
Multi Ogre ArcFull Sync - Channel
UniMove Atomic - Channel
UniMove Crossbeam - Channel
UniMove Full Sync - Channel
UniZero Copy Atomic - Channel
UniZero Copy Full Sync - Connection
Id - Messaging
Mutiny Stream - Concrete type of the
Stream
s this crate produces.
Type for theStream
we create when reading from the remote peer.
This type is intended to be used only for the first level ofdialog_processor_builder()
s you pass to the [SocketClient] or [SocketServer], as Rust Generics isn’t able to infer a genericStream
type in this situation (in which theStream
is created inside the generic function itself).
If your logic uses functions that receiveStream
s, you’ll want flexibility to do whatever you want with theStream
(which would no longer be aMutinyStream
), so declare such functions as: - Multi
Arc - Default
Multi
for those who wants to useArc
as the wrapping type for payloads - Multi
Atomic Arc - Multi
Atomic Ogre Arc - Multi
Crossbeam Arc - Multi
Full Sync Arc - Multi
Full Sync Ogre Arc - Multi
Mmap Log - Multi
Ogre Arc - Default
Multi
for those who want the more performant OgreArc as the wrapping type for their payloads - UniMove
- Default
UniBuilder
for “moving” data around – good for small payloads (< 1k) whose types don’t require a customDrop
function - UniMove
Atomic - UniMove
Crossbeam - UniMove
Full Sync - UniZero
Copy - Default ‘UniBuilder’ for “zero-copying” data that will either be shared around or has a reasonably “big” payload (> 1k)
- UniZero
Copy Atomic - UniZero
Copy Full Sync