Macro tonic::include_file_descriptor_set[][src]

macro_rules! include_file_descriptor_set {
    ($package: tt) => { ... };

Include an encoded prost_types::FileDescriptorSet as a &'static [u8]. The parameter must be the stem of the filename passed to file_descriptor_set_path for the tonic-build::Builder, excluding the .bin extension.

For example, a file descriptor set compiled like this in

let descriptor_path = PathBuf::from(env::var("OUT_DIR").unwrap()).join("my_descriptor.bin")
    .compile(&["proto/reflection.proto"], &["proto/"])?;

Can be included like this:

mod pb {
    pub(crate) const FILE_DESCRIPTOR_SET: &[u8] = tonic::include_file_descriptor_set!("my_descriptor");


This only works if the tonic-build output directory has been unmodified. The default output directory is set to the [OUT_DIR] environment variable. If the output directory has been modified, the following pattern may be used instead of this macro.

mod pb {
    pub(crate) const FILE_DESCRIPTOR_SET: &[u8] = include_bytes!("/relative/protobuf/directory/descriptor_name.bin");