Skip to main content

ttrpc_compiler/
lib.rs

1// Copyright 2017 PingCAP, Inc.
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7//     http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// See the License for the specific language governing permissions and
12// limitations under the License.
13
14//! Low-level service generator for ttrpc Rust bindings.
15//!
16//! This crate turns Protocol Buffers file descriptors into generated ttrpc clients, server traits,
17//! and registration helpers. Most projects should use [`ttrpc-codegen`] from `build.rs`; it parses
18//! `.proto` files and calls this compiler internally. The `ttrpc_rust_plugin` binary exposes the
19//! same generator through the standard `protoc` plugin protocol.
20//!
21//! [`ttrpc-codegen`]: https://docs.rs/ttrpc-codegen
22
23#![warn(missing_docs)]
24#![warn(rustdoc::broken_intra_doc_links)]
25
26/// Generates ttrpc service bindings from Protocol Buffers descriptors.
27pub mod codegen;
28mod util;
29
30/// Customize generated code.
31#[derive(Default, Debug, Clone)]
32pub struct Customize {
33    /// Indicates whether to generate async code for both server and client.
34    pub async_all: bool,
35    /// Indicates whether to generate async code for the client.
36    pub async_client: bool,
37    /// Indicates whether to generate async code for server.
38    pub async_server: bool,
39    /// Generates or updates `mod.rs` in the output directory.
40    pub gen_mod: bool,
41}