coralstack-cmd-ipc 0.1.0

Inter-Process Communication library for running typed Commands across processes and services
Documentation
//! Rust port of [`@coralstack/cmd-ipc`](https://github.com/CoralStack/cmd-ipc).
//!
//! The wire protocol is byte-identical to the TypeScript library, so Rust
//! and Node.js processes can exchange commands over any channel that
//! carries JSON.
//!
//! This crate is runtime-agnostic: it depends on the `futures` primitives
//! only, and does not pull in tokio, async-std, or smol. Users drive the
//! per-channel pump future returned by `CommandRegistry::register_channel`
//! with the executor of their choice.
//!
//! See [`message`] for the wire format, [`ttl_map`] for the storage
//! primitive shared by the registry's reply/route/event tables, and
//! [`macro@command`] / [`macro@command_service`] / [`macro@event`] /
//! [`macro@payload`] for the attribute macros that let you register
//! commands and events next to the code that implements them.

pub mod channel;
pub mod command;
pub mod error;
pub mod event;
pub mod message;
pub mod registry;
pub mod schema;
pub mod ttl_map;

pub use channel::{CommandChannel, InMemoryChannel};
pub use command::{BoxedDynCommand, BoxedHandler, Command, DynCommand};
pub use error::{ChannelError, CommandError, ExecuteErrorCode, RegisterErrorCode};
pub use event::{DynEvent, Event};
pub use message::{
    CommandDef, CommandSchema, ExecuteError, ExecuteResult, False, Message, MessageId,
    RegisterResult, True,
};
pub use registry::{CommandRegistry, Config};

pub use schema::normalize_schema;
pub use ttl_map::TtlMap;

// Re-exports for use by code generated by the `#[command]` /
// `#[command_service]` / `#[event]` / `#[payload]` macros, AND for
// convenience so user crates that only depend on `coralstack-cmd-ipc`
// can still reach into `serde` / `schemars` / `serde_json` when they
// want to.
//
// `serde` is re-exported so the derives emitted by `#[event]` and
// `#[payload]` resolve against it without the user adding a direct
// dependency. The `#[serde(crate = "...")]` / `#[schemars(crate = "...")]`
// attributes the macros emit point at these re-exports.
pub use coralstack_cmd_ipc_macros::{command, command_service, event, payload};
pub use schemars;
pub use serde;
pub use serde_json;

/// Curated re-exports for the common public API.
///
/// ```ignore
/// use coralstack_cmd_ipc::prelude::*;
/// ```
pub mod prelude {
    pub use crate::{
        command, command_service, event, payload, BoxedDynCommand, ChannelError, Command,
        CommandChannel, CommandDef, CommandError, CommandRegistry, CommandSchema, Config,
        DynCommand, DynEvent, Event, InMemoryChannel,
    };
}