1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
//! `RsCNI` is a CNI plugin library for Rust.
//! `RsCNI` helps you to implement CNI plugins easily by abstracting common operations.
//! `RsCNI` offers trait based design for both sync and async CNI plugins.
//!
//! The entry point is the `Plugin` struct in the `cni` or `async_cni` module.
//! Your CNI plugin struct should implement the `Cni` trait defined in the respective module.
//!
//! Please see [rscni-debug](github.com/terassyi/rscni/blob/main/examples/README.md) for the example implementation.
//! To use async version of rscni, please use it with `feature=async` flag.
//! The usage of async version, see [async-rscni-debug](github.com/terassyi/rscni/blob/main/examples/async-rscni-debug/main.rs).
//!
//! # Quick start
//!
//! ```rust,no_run
//! # use rscni::{
//! # cni::{Cni, Plugin},
//! # error::Error,
//! # types::{Args, CNIResult},
//! # };
//! #
//! # struct MyPlugin;
//! #
//! # impl Cni for MyPlugin {
//! # fn add(&self, args: Args) -> Result<CNIResult, Error> {
//! # // Implement network setup logic
//! # Ok(CNIResult::default())
//! # }
//! #
//! # fn del(&self, args: Args) -> Result<CNIResult, Error> {
//! # // Implement network teardown logic
//! # Ok(CNIResult::default())
//! # }
//! #
//! # fn check(&self, args: Args) -> Result<CNIResult, Error> {
//! # // Implement network check logic
//! # Ok(CNIResult::default())
//! # }
//! #
//! # fn status(&self, _args: Args) -> Result<(), Error> {
//! # // Implement plugin readiness check
//! # Ok(())
//! # }
//! #
//! # fn gc(&self, _args: Args) -> Result<(), Error> {
//! # // Implement garbage collection logic
//! # Ok(())
//! # }
//! # }
//! #
//! let my_plugin = MyPlugin;
//! let plugin = Plugin::default();
//! plugin.run(&my_plugin).expect("Failed to run CNI plugin");
//! ```
pub