Skip to main content

Crate wabot_feature_chat_controller

Crate wabot_feature_chat_controller 

Source
Expand description

§wabot-feature-chat-controller

Rust port of wabot-ts/src/feature/chat-controller. Provides:

  • ChatChannel trait + ChannelMessage / ReceivedMessage types.
  • Chat entity, ChatRepository, ChatResolver (in-memory; Phase 4 will graduate these into a dedicated wabot-feature-chat-bot crate alongside the Postgres implementation).
  • The runtime helpers macro emissions call into.

The #[chat_controller] macro lives in wabot-macros. Per-channel markers (#[cmd], future #[telegram(...)] / #[socket(...)]) are also there.

Re-exports§

pub use channel::ChannelError;
pub use channel::ChannelMessage;
pub use channel::ChatChannel;
pub use channel::InjectInstance;
pub use channel::MessageCallback;
pub use channel::ReplyFn;
pub use channel::ReplyResult;
pub use handler::Dispatch;
pub use handler::DispatchArgs;
pub use handler::DispatchError;
pub use handler::ReceivedMessage;
pub use handler::ReplyHandle;
pub use runtime::build_message_callback;
pub use runtime::into_received;
pub use runtime::populate_child_container;
pub use runtime::run_chat_controllers;
pub use async_trait;

Modules§

channel
IChatChannel trait + channel-side message types.
chat
Re-export of the chat-bot Chat entity + repository.
handler
Inbound-message handler trait — the typed bridge between channels and macro-generated dispatch code.
runtime
Per-message runtime — shared by every #[chat_controller] macro emission. Centralising the child-container / chat-resolution plumbing here keeps the macro emission small.
types
Re-export of the chat-bot data types.

Structs§

ChatConnection
Identifies a chat at the channel level. Same shape as IChatConnection in TS. The (channel_name, id) pair is unique.
ChatData
Persistent chat state. Multi-channel-capable.
ChatMessage
One chat message — inbound (received from a channel) or outbound (a reply, or a bot-generated message from the LLM). Mirrors IChatMessage in TS.
ChatMessageFile
File attachment on a chat message — image or document. Either public_url or base64_url must be set; readers fall back through them in that order.
ChatResolver
Make-or-find lookup keyed on (channel_name, connection_id). Uses a per-key tokio::sync::Mutex so concurrent first-time messages from the same connection serialize their create attempts; horizontal scaling needs the full Locker port (Phase 5).
InMemoryChatRepository
In-memory repository — fine for examples and tests.

Enums§

ChatType
Whether a chat is one-on-one or group. Mirrors IChatConnection.chatType ('PRIVATE' | 'GROUP') from TS.

Traits§

ChatRepository
Storage interface for Chat lookups.

Functions§

chat_from_connection
Build a fresh Chat from a single connection. Free function rather than an inherent impl because Chat is a type alias (orphan rule).

Type Aliases§

Chat