Module sozu_command_lib::proto

source ·
Expand description

Contains Rust types generated by prost using the protobuf definition in command.proto.

The two main types are Request and Response.

Because these types were originally defined in Rust, and later adapted for protobuf, the Rust translation of the protobuf definition looks a bit weird. Instead of having Request being a simple enum with Payload like this:

pub enum Request {
    SaveState(String),
    LoadState(String),
    // ...
}

It is defined with oneof in protobuf. and looks like this in Rust:

pub struct Request {
    pub request_type: ::core::option::Option<request::RequestType>,
}

pub mod request {
    pub enum RequestType {
        #[prost(string, tag = "1")]
        SaveState(::prost::alloc::string::String),
        /// load a state file, given its path
        #[prost(string, tag = "2")]
        LoadState(::prost::alloc::string::String),
    }
}

but can be instantiated this way:

let load_state_request: Request = RequestType::LoadState(path).into();

A bit cumbersome, but it is the only way to benefit from protobuf in Rust.

Modules§

  • Contains all types received by and sent from Sōzu
  • Implementation of fmt::Display for the protobuf types, used in the CLI

Enums§