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
/// A macro that creates an [`Extension`](crate::extensions::Extension) and adds it to a [`FileBuilder`](crate::files::FileBuilder).
///
/// The first argument is the ident for the [`FileBuilder`](crate::files::FileBuilder) where this extension will go.
/// The second argument is an ident that will be matched with a variant of [`ExtensionKind`](crate::extensions::ExtensionKind) enum (i.e. MessageOptions, FileOptions, etc).
/// The fields for the extension are defined as a comma separated list of `$field_number:literal => $field:expr` surrounded by curly brackets, where $field evalutes to a [`FieldBuilder`](crate::fields::FieldBuilder) instance.
/// Options for the fields themselves can be defined by calling [`add_option`](crate::fields::FieldBuilder::add_option) on the field builder.
/// # Examples
/// ```
/// use protoschema::{Package, extension, string, reusable_fields};
///
/// let package = Package::new("mypkg");
/// let file = package.new_file("myfile");
///
/// let shared_fields = reusable_fields!(
/// 151 => string!("metadata_1"),
/// 152 => string!("metadata_2"),
/// );
///
/// extension!(
/// file,
/// MessageOptions {
/// // Add a normal field
/// 150 => string!("abc"),
/// // Include reusable fields
/// include(shared_fields)
/// }
/// );
/// ```