5个版本

0.5.4 2024年6月12日
0.5.3 2024年6月12日
0.5.2 2024年6月12日
0.5.1 2024年6月12日
0.5.0 2024年6月10日

#819算法

Download history 310/week @ 2024-06-08 61/week @ 2024-06-15 9/week @ 2024-06-22 16/week @ 2024-06-29 48/week @ 2024-07-27

61 每月下载量
2 crates 中使用

MIT 许可证

9KB
139

Crates.io MIT licensed Build Status

krossbar-state-machine

Krossbar状态机

在多个Krossbar服务中使用的平面状态机。

该库提供了一种结构,能够支持异步函数内部的内部状态。这允许将其用作客户端状态机。如果不需要其特定功能,作为独立库则不太有用。

示例

use krossbar_machine::{control::Control, machine::Machine};

async fn up_to_45(value: i32) -> Control<i32, i32> {
    if value < 45 {
        Control::Loop(value + 1)
    } else {
        Control::Return(value)
    }
}

fn hello(value: i32) -> String {
    format!("Hello {value}!")
}

async fn example() {
    let mach = Machine::init(42).then(up_to_45).ret(hello);

    assert_eq!("Hello 45!", mach.await);
}

依赖项

~1MB
~15K SLoC