Skip to main content

Crate industrial_protocols_async_layer

Crate industrial_protocols_async_layer 

Source
Expand description

§异步层(可选)

基于 tokio 的异步包装层,将同步内核 API 包装为 async 方法。

§核心组件

  • AsyncKernel — 使用 tokio::sync::Mutex 包装 Kernel,提供异步 boot/shutdown/read/write
  • AsyncEventStream — 将内核的同步 [EventBus] 事件转为 tokio 异步流

§使用示例

ⓘ
use industrial_protocols_async_layer::*;
use industrial_protocols_kernel::*;
use industrial_protocols_kernel::event::EventTopic;

let kernel = Kernel::builder()
    .with_protocol(Box::new(MyProtocol))
    .build();

let stream = AsyncEventStream::subscribe(&kernel, EventTopic::Connection);

let ak = AsyncKernel::new(kernel);
ak.boot().await?;

Structs§

AsyncEventStream
AsyncKernel