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 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118
/*
Copyright The containerd Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
//! `containerd-shim-protos` contains TTRPC bindings and client/server code to interact with
//! containerd's runtime v2 shims.
//!
//! # Runtime
//! This crate is mainly expected to be useful to interact with containerd's shim runtime.
//! Runtime v2 introduces a first class shim API for runtime authors to integrate with containerd.
//! The shim API is minimal and scoped to the execution lifecycle of a container.
//!
//! To learn how containerd's shim v2 runtime works in details, please refer to the [documentation](https://github.com/containerd/containerd/blob/main/runtime/v2/README.md).
//!
//! # Design
//! The `containerd-shim-protos` crate provides [Protobuf](https://github.com/protocolbuffers/protobuf.git) message
//! and [TTRPC](https://github.com/containerd/ttrpc.git) service definitions for the
//! [Containerd shim v2](https://github.com/containerd/containerd/blob/main/runtime/v2/task/shim.proto) protocol.
//!
//! The message and service definitions are auto-generated from protobuf source files under `vendor/`
//! by using [ttrpc-codegen](https://github.com/containerd/ttrpc-rust/tree/master/ttrpc-codegen). So please do not
//! edit those auto-generated source files.
//!
//! If upgrading/modification is needed, please follow the steps:
//! - Synchronize the latest protobuf source files from the upstream projects into directory 'vendor/'.
//! - Re-generate the source files by `cargo build --features=generate_bindings`.
//! - Commit the synchronized protobuf source files and auto-generated source files, keeping them in synchronization.
//!
//! # Examples
//!
//! Here is a quick example how to use the crate:
//! ```no_run
//! use containerd_shim_protos as client;
//!
//! use client::api;
//! use client::ttrpc::context::Context;
//!
//! // Create TTRPC client
//! let client = client::Client::connect("unix:///socket.sock").unwrap();
//!
//! // Get task client
//! let task_client = client::TaskClient::new(client);
//! let context = Context::default();
//!
//! // Send request and receive response
//! let request = api::ConnectRequest::default();
//! let response = task_client.connect(Context::default(), &request);
//! ```
//!
#![allow(warnings)]
pub use protobuf;
pub use ttrpc;
pub mod cgroups;
pub mod events;
#[cfg(feature = "sandbox")]
mod sandbox;
pub mod shim;
pub mod types;
pub mod windows;
/// Includes event names shims can publish to containerd.
pub mod topics;
pub mod shim_sync {
/// TTRPC client reexport for easier access.
pub use ttrpc::Client;
/// Shim events service.
pub use crate::shim::events_ttrpc::{create_events, Events, EventsClient};
/// Shim task service.
pub use crate::shim::shim_ttrpc::{create_task, Task, TaskClient};
}
pub use shim_sync::*;
#[cfg(feature = "async")]
pub mod shim_async {
/// TTRPC client reexport for easier access.
pub use ttrpc::asynchronous::Client;
/// Shim events service.
pub use crate::shim::events_ttrpc_async::{create_events, Events, EventsClient};
/// Shim task service.
pub use crate::shim::shim_ttrpc_async::{create_task, Task, TaskClient};
}
/// Reexport auto-generated public data structures.
pub mod api {
pub use crate::shim::{empty::*, events::*, mount::*, shim::*, task::*};
}
#[cfg(feature = "sandbox")]
pub use sandbox::sandbox as sandbox_api;
#[cfg(feature = "sandbox")]
pub mod sandbox_sync {
pub use crate::sandbox::sandbox_ttrpc::*;
}
#[cfg(all(feature = "sandbox", feature = "async"))]
pub mod sandbox_async {
pub use crate::sandbox::sandbox_async::*;
}