Skip to main content

rtcom_core/
lib.rs

1//! Core library for [rtcom](https://github.com/TrekMax/rtcom) — Rust Terminal Communication.
2//!
3//! At v0.1 this crate provides:
4//!
5//! - [`SerialDevice`] — async serial-port abstraction (Issue #2).
6//! - [`SerialPortDevice`] — default backend built on [`tokio_serial`].
7//! - [`SerialConfig`] and companion enums — the framing and flow parameters.
8//! - [`Event`] and [`EventBus`] — cross-task event hub (Issue #5).
9//! - [`Session`] — the orchestrator that drives serial I/O against the bus.
10//! - [`Error`] / [`Result`] — the crate-wide error type.
11//!
12//! Later issues layer the event bus, session orchestrator, mappers, and
13//! command state machine on top of this foundation. See `CLAUDE.md` §7 for
14//! the full v0.1 plan.
15//!
16//! # Example
17//!
18//! ```no_run
19//! use rtcom_core::{SerialConfig, SerialDevice, SerialPortDevice};
20//! use tokio::io::AsyncWriteExt;
21//!
22//! # async fn run() -> rtcom_core::Result<()> {
23//! let mut port = SerialPortDevice::open("/dev/ttyUSB0", SerialConfig::default())?;
24//! port.write_all(b"hello\r\n").await?;
25//! # Ok(()) }
26//! ```
27
28#![forbid(unsafe_code)]
29
30pub mod command;
31pub mod config;
32pub mod device;
33pub mod error;
34pub mod event;
35pub mod lock;
36pub mod mapper;
37pub mod session;
38
39pub use command::{Command, CommandKeyParser, ParseOutput};
40pub use config::{
41    DataBits, FlowControl, ModemStatus, Parity, SerialConfig, StopBits, DEFAULT_READ_TIMEOUT,
42};
43pub use device::{SerialDevice, SerialPortDevice};
44pub use error::{Error, Result};
45pub use event::{Event, EventBus, DEFAULT_BUS_CAPACITY};
46pub use lock::UucpLock;
47pub use mapper::{LineEnding, LineEndingMapper, Mapper};
48pub use session::Session;