use crate::wire_format;
pub struct MessageDescriptor {
pub name: &'static str,
pub full_name: &'static str,
pub fields: &'static [FieldDescriptor],
pub oneofs: &'static [OneofDescriptor],
}
pub struct FieldDescriptor {
pub name: &'static str,
pub full_name: &'static str,
pub index: u32,
pub number: u32,
pub typ: wire_format::Type,
pub label: Label,
pub oneof_index: Option<u32>,
}
#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug)]
pub enum Label {
Optional = 1,
Required = 2,
Repeated = 3,
}
pub struct OneofDescriptor {
pub name: &'static str,
}
impl MessageDescriptor {
pub fn get_field(&self, name: &str) -> Option<&FieldDescriptor> {
self.fields.iter().find(|f| f.name == name)
}
}