message_bus
Generated Rust API reference for byte_engine.
byte_engine / core / message_bus
Module message_bus
Startup-sized storage shared by the engine's typed message routes.
Create one MessageBus during application startup, then create a
MessageScope for each independently owned group of channels. Message
types are registered lazily the first time a channel requests them.
Quick Reference
| Item | Kind | Description |
|---|---|---|
MessageBusConfig | struct | The MessageBusConfig struct defines the fixed storage limits reserved at startup. |
TopicSnapshot | struct | The TopicSnapshot struct reports one typed route's current state for diagnostics. |
MessageBus | struct | The MessageBus struct owns one fixed heterogeneous payload arena and its lazy route registry. |
MessageScope | struct | The MessageScope struct isolates typed routes owned by one subsystem while sharing bus storage. |
MessageBusConfigError | enum | The MessageBusConfigError enum explains why startup storage cannot be allocated. |
MessageRouteError | enum | The MessageRouteError enum explains why a lazy typed route cannot be acquired. |
Structs
MessageBusConfig
struct MessageBusConfig {
pub max_topics: usize,
pub cells_per_topic: usize,
pub cell_bytes: usize,
pub cell_alignment: usize,
pub max_listeners_per_topic: usize,
}Defined in crates/byte-engine/src/core/message_bus.rs:33-44
The MessageBusConfig struct defines the fixed storage limits reserved at startup.
Fields
-
max_topics:usizeMaximum number of typed routes across every scope.
-
cells_per_topic:usizeNumber of fixed cells reserved for each typed route.
-
cell_bytes:usizeNumber of payload bytes in one cell.
-
cell_alignment:usizeAlignment of every payload cell.
-
max_listeners_per_topic:usizeMaximum number of simultaneous listeners on one typed route.
Implementations
-
fn new(max_topics: usize, cells_per_topic: usize, cell_bytes: usize) -> SelfCreates fixed message storage with the supplied route and cell limits.
Next, adjust alignment or listener limits if the application needs values
outside the defaults, then pass the result to
MessageBus::new. -
fn with_cell_alignment(self, cell_alignment: usize) -> SelfReturns this configuration with a replacement payload alignment.
-
fn with_max_listeners_per_topic(self, max_listeners_per_topic: usize) -> SelfReturns this configuration with a replacement per-topic listener limit.
Trait Implementations
impl ArchivePointee for MessageBusConfig
-
type ArchivedMetadata = () -
fn pointer_metadata(_: &<T as ArchivePointee>::ArchivedMetadata) -> <T as Pointee>::Metadata
impl<ST> CastableFrom for MessageBusConfig
impl Clone for MessageBusConfig
-
fn clone(&self) -> MessageBusConfigRelated:
MessageBusConfig
impl Copy for MessageBusConfig
impl Debug for MessageBusConfig
-
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result
impl Default for MessageBusConfig
-
fn default() -> Self
impl Downcast for MessageBusConfig
-
fn into_any(self: Box<T>) -> Box<dyn Any> -
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any> -
fn as_any(&self) -> &dyn Any -
fn as_any_mut(&mut self) -> &mut dyn Any
impl DowncastSend for MessageBusConfig
-
fn into_any_send(self: Box<T>) -> Box<dyn Any + Send>
impl DowncastSync for MessageBusConfig
-
fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Sync + Send>
impl Eq for MessageBusConfig
impl<K> Equivalent for MessageBusConfig
-
fn equivalent(&self, key: &K) -> bool
impl Instrument for MessageBusConfig
impl LayoutRaw for MessageBusConfig
-
fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
impl<T, N1> Niching for MessageBusConfig
-
unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool -
fn resolve_niched(out: Place<NichedOption<T, N1>>)
impl PartialEq for MessageBusConfig
-
fn eq(&self, other: &MessageBusConfig) -> boolRelated:
MessageBusConfig
impl Pointable for MessageBusConfig
-
const ALIGN: usize -
type Init = T -
unsafe fn init(init: <T as Pointable>::Init) -> usize -
unsafe fn deref<'a>(ptr: usize) -> &'a T -
unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T -
unsafe fn drop(ptr: usize)
impl Pointee for MessageBusConfig
-
type Metadata = ()
impl Read for MessageBusConfig
impl<R> ReadPrimitive for MessageBusConfig
impl StructuralPartialEq for MessageBusConfig
impl WithSubscriber for MessageBusConfig
TopicSnapshot
struct TopicSnapshot {
pub topic_id: usize,
pub scope_id: u64,
pub scope: std::sync::Arc<str>,
pub message_type: &'static str,
pub capacity: usize,
pub active_listeners: usize,
pub queued_for_slowest_listener: usize,
pub published: u64,
pub full: u64,
pub disconnected: u64,
}Defined in crates/byte-engine/src/core/message_bus.rs:252-263
The TopicSnapshot struct reports one typed route's current state for diagnostics.
Trait Implementations
impl ArchivePointee for TopicSnapshot
-
type ArchivedMetadata = () -
fn pointer_metadata(_: &<T as ArchivePointee>::ArchivedMetadata) -> <T as Pointee>::Metadata
impl<ST> CastableFrom for TopicSnapshot
impl Clone for TopicSnapshot
-
fn clone(&self) -> TopicSnapshotRelated:
TopicSnapshot
impl Debug for TopicSnapshot
-
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result
impl Downcast for TopicSnapshot
-
fn into_any(self: Box<T>) -> Box<dyn Any> -
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any> -
fn as_any(&self) -> &dyn Any -
fn as_any_mut(&mut self) -> &mut dyn Any
impl DowncastSend for TopicSnapshot
-
fn into_any_send(self: Box<T>) -> Box<dyn Any + Send>
impl DowncastSync for TopicSnapshot
-
fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Sync + Send>
impl Eq for TopicSnapshot
impl<K> Equivalent for TopicSnapshot
-
fn equivalent(&self, key: &K) -> bool
impl Instrument for TopicSnapshot
impl LayoutRaw for TopicSnapshot
-
fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
impl<T, N1> Niching for TopicSnapshot
-
unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool -
fn resolve_niched(out: Place<NichedOption<T, N1>>)
impl PartialEq for TopicSnapshot
-
fn eq(&self, other: &TopicSnapshot) -> boolRelated:
TopicSnapshot
impl Pointable for TopicSnapshot
-
const ALIGN: usize -
type Init = T -
unsafe fn init(init: <T as Pointable>::Init) -> usize -
unsafe fn deref<'a>(ptr: usize) -> &'a T -
unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T -
unsafe fn drop(ptr: usize)
impl Pointee for TopicSnapshot
-
type Metadata = ()
impl Read for TopicSnapshot
impl StructuralPartialEq for TopicSnapshot
impl WithSubscriber for TopicSnapshot
MessageBus
struct MessageBus {
// [REDACTED: Private Fields]
}Defined in crates/byte-engine/src/core/message_bus.rs:267-269
The MessageBus struct owns one fixed heterogeneous payload arena and its lazy route registry.
Implementations
-
fn new(config: MessageBusConfig) -> Result<Self, MessageBusConfigError>Related:
MessageBusConfig,MessageBusConfigErrorAllocates the complete payload arena and route metadata.
Next, call
Self::new_scopefor each owner that needs isolated typedroutes, then acquire channels or factories from that scope.
-
fn config(&self) -> MessageBusConfigRelated:
MessageBusConfigReturns the immutable startup limits for this bus.
-
fn observe(&self) -> Result<MessageObserver, MessageObservationError>Related:
MessageObserver,MessageObservationErrorAttaches the one passive observer for this bus.
The observer sees successful publications from every future route,
including application-defined generic types. Attach it before acquiring
the first channel or factory. Publication observation reads existing route
counters, so it never delays publishers.
-
fn new_scope(&self, name: impl Into<Arc<str>>) -> MessageScopeRelated:
MessageScopeCreates an isolated namespace over the same fixed arena.
Routes remain lazy: creating a scope does not claim a topic until code
requests a concrete message type from it.
-
fn topics(&self) -> Vec<TopicSnapshot>Related:
TopicSnapshotReturns diagnostic snapshots for every route registered so far.
Trait Implementations
impl ArchivePointee for MessageBus
-
type ArchivedMetadata = () -
fn pointer_metadata(_: &<T as ArchivePointee>::ArchivedMetadata) -> <T as Pointee>::Metadata
impl<ST> CastableFrom for MessageBus
impl Clone for MessageBus
-
fn clone(&self) -> MessageBusRelated:
MessageBus
impl Default for MessageBus
-
fn default() -> Self
impl Downcast for MessageBus
-
fn into_any(self: Box<T>) -> Box<dyn Any> -
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any> -
fn as_any(&self) -> &dyn Any -
fn as_any_mut(&mut self) -> &mut dyn Any
impl DowncastSend for MessageBus
-
fn into_any_send(self: Box<T>) -> Box<dyn Any + Send>
impl DowncastSync for MessageBus
-
fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Sync + Send>
impl Instrument for MessageBus
impl LayoutRaw for MessageBus
-
fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
impl<T, N1> Niching for MessageBus
-
unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool -
fn resolve_niched(out: Place<NichedOption<T, N1>>)
impl Pointable for MessageBus
-
const ALIGN: usize -
type Init = T -
unsafe fn init(init: <T as Pointable>::Init) -> usize -
unsafe fn deref<'a>(ptr: usize) -> &'a T -
unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T -
unsafe fn drop(ptr: usize)
impl Pointee for MessageBus
-
type Metadata = ()
impl Read for MessageBus
impl<R> ReadPrimitive for MessageBus
impl WithSubscriber for MessageBus
MessageScope
struct MessageScope {
// [REDACTED: Private Fields]
}Defined in crates/byte-engine/src/core/message_bus.rs:382-386
The MessageScope struct isolates typed routes owned by one subsystem while sharing bus storage.
Implementations
-
fn channel<M>(&self) -> DefaultChannel<M>Acquires the canonical typed channel in this scope, registering it on first use.
Next, create listeners before publishing messages that they must observe.
-
fn try_channel<M>(&self) -> Result<DefaultChannel<M>, MessageRouteError>Related:
MessageRouteErrorTries to acquire the canonical typed channel in this scope.
-
fn factory<T>(&self) -> Factory<T>Acquires the canonical creation factory for
Tin this scope.The factory registers
CreateMessage<T>only when this method is firstcalled, so application-defined types require no startup declaration.
-
fn name(&self) -> &strReturns this scope's diagnostic name.
-
fn topics(&self) -> Vec<TopicSnapshot>Related:
TopicSnapshotReturns diagnostic snapshots for routes registered in this scope.
Trait Implementations
impl ArchivePointee for MessageScope
-
type ArchivedMetadata = () -
fn pointer_metadata(_: &<T as ArchivePointee>::ArchivedMetadata) -> <T as Pointee>::Metadata
impl<ST> CastableFrom for MessageScope
impl Clone for MessageScope
-
fn clone(&self) -> MessageScopeRelated:
MessageScope
impl Debug for MessageScope
-
fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result
impl Downcast for MessageScope
-
fn into_any(self: Box<T>) -> Box<dyn Any> -
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any> -
fn as_any(&self) -> &dyn Any -
fn as_any_mut(&mut self) -> &mut dyn Any
impl DowncastSend for MessageScope
-
fn into_any_send(self: Box<T>) -> Box<dyn Any + Send>
impl DowncastSync for MessageScope
-
fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Sync + Send>
impl Instrument for MessageScope
impl LayoutRaw for MessageScope
-
fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
impl<T, N1> Niching for MessageScope
-
unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool -
fn resolve_niched(out: Place<NichedOption<T, N1>>)
impl Pointable for MessageScope
-
const ALIGN: usize -
type Init = T -
unsafe fn init(init: <T as Pointable>::Init) -> usize -
unsafe fn deref<'a>(ptr: usize) -> &'a T -
unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T -
unsafe fn drop(ptr: usize)
impl Pointee for MessageScope
-
type Metadata = ()
impl Read for MessageScope
impl WithSubscriber for MessageScope
Enums
MessageBusConfigError
enum MessageBusConfigError {
ZeroLimit(&'static str),
InvalidAlignment(usize),
MisalignedCellSize {
cell_bytes: usize,
cell_alignment: usize,
},
StorageSizeOverflow,
}Defined in crates/byte-engine/src/core/message_bus.rs:148-157
The MessageBusConfigError enum explains why startup storage cannot be allocated.
Variants
-
ZeroLimitA required limit was zero.
-
InvalidAlignmentThe configured cell alignment was not a nonzero power of two.
-
MisalignedCellSizeThe cell size was not a multiple of its alignment.
-
StorageSizeOverflowThe requested arena size exceeded addressable memory.
Trait Implementations
impl ArchivePointee for MessageBusConfigError
-
type ArchivedMetadata = () -
fn pointer_metadata(_: &<T as ArchivePointee>::ArchivedMetadata) -> <T as Pointee>::Metadata
impl<ST> CastableFrom for MessageBusConfigError
impl Clone for MessageBusConfigError
-
fn clone(&self) -> MessageBusConfigErrorRelated:
MessageBusConfigError
impl Debug for MessageBusConfigError
-
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result
impl Display for MessageBusConfigError
-
fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result
impl Downcast for MessageBusConfigError
-
fn into_any(self: Box<T>) -> Box<dyn Any> -
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any> -
fn as_any(&self) -> &dyn Any -
fn as_any_mut(&mut self) -> &mut dyn Any
impl DowncastSend for MessageBusConfigError
-
fn into_any_send(self: Box<T>) -> Box<dyn Any + Send>
impl DowncastSync for MessageBusConfigError
-
fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Sync + Send>
impl Eq for MessageBusConfigError
impl<K> Equivalent for MessageBusConfigError
-
fn equivalent(&self, key: &K) -> bool
impl Error for MessageBusConfigError
impl Instrument for MessageBusConfigError
impl LayoutRaw for MessageBusConfigError
-
fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
impl<T, N1> Niching for MessageBusConfigError
-
unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool -
fn resolve_niched(out: Place<NichedOption<T, N1>>)
impl PartialEq for MessageBusConfigError
-
fn eq(&self, other: &MessageBusConfigError) -> boolRelated:
MessageBusConfigError
impl Pointable for MessageBusConfigError
-
const ALIGN: usize -
type Init = T -
unsafe fn init(init: <T as Pointable>::Init) -> usize -
unsafe fn deref<'a>(ptr: usize) -> &'a T -
unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T -
unsafe fn drop(ptr: usize)
impl Pointee for MessageBusConfigError
-
type Metadata = ()
impl Read for MessageBusConfigError
impl StructuralPartialEq for MessageBusConfigError
impl ToString for MessageBusConfigError
-
fn to_string(&self) -> String
impl WithSubscriber for MessageBusConfigError
MessageRouteError
enum MessageRouteError {
TopicLimit {
message_type: &'static str,
max_topics: usize,
},
MessageTooLarge {
message_type: &'static str,
message_bytes: usize,
available_bytes: usize,
},
MessageOveraligned {
message_type: &'static str,
required_alignment: usize,
cell_alignment: usize,
},
ListenerLimit {
message_type: &'static str,
max_listeners: usize,
},
}Defined in crates/byte-engine/src/core/message_bus.rs:189-209
The MessageRouteError enum explains why a lazy typed route cannot be acquired.
Variants
-
TopicLimitThe bus has no unclaimed topic slab.
-
MessageTooLargeOne message cannot fit in its topic slab.
-
MessageOveralignedThe message requires stricter alignment than the arena provides.
-
ListenerLimitThe route has no free listener descriptor.
Trait Implementations
impl ArchivePointee for MessageRouteError
-
type ArchivedMetadata = () -
fn pointer_metadata(_: &<T as ArchivePointee>::ArchivedMetadata) -> <T as Pointee>::Metadata
impl<ST> CastableFrom for MessageRouteError
impl Clone for MessageRouteError
-
fn clone(&self) -> MessageRouteErrorRelated:
MessageRouteError
impl Debug for MessageRouteError
-
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result
impl Display for MessageRouteError
-
fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result
impl Downcast for MessageRouteError
-
fn into_any(self: Box<T>) -> Box<dyn Any> -
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any> -
fn as_any(&self) -> &dyn Any -
fn as_any_mut(&mut self) -> &mut dyn Any
impl DowncastSend for MessageRouteError
-
fn into_any_send(self: Box<T>) -> Box<dyn Any + Send>
impl DowncastSync for MessageRouteError
-
fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Sync + Send>
impl Eq for MessageRouteError
impl<K> Equivalent for MessageRouteError
-
fn equivalent(&self, key: &K) -> bool
impl Error for MessageRouteError
impl Instrument for MessageRouteError
impl LayoutRaw for MessageRouteError
-
fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
impl<T, N1> Niching for MessageRouteError
-
unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool -
fn resolve_niched(out: Place<NichedOption<T, N1>>)
impl PartialEq for MessageRouteError
-
fn eq(&self, other: &MessageRouteError) -> boolRelated:
MessageRouteError
impl Pointable for MessageRouteError
-
const ALIGN: usize -
type Init = T -
unsafe fn init(init: <T as Pointable>::Init) -> usize -
unsafe fn deref<'a>(ptr: usize) -> &'a T -
unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T -
unsafe fn drop(ptr: usize)
impl Pointee for MessageRouteError
-
type Metadata = ()
impl Read for MessageRouteError
impl StructuralPartialEq for MessageRouteError
impl ToString for MessageRouteError
-
fn to_string(&self) -> String