rustling 0.8.0

A blazingly fast library for computational linguistics
Documentation
// automatically generated by the FlatBuffers compiler, do not modify
// @generated
extern crate alloc;


#[allow(unused_imports, dead_code)]
pub mod rustling {

#[allow(unused_imports, dead_code)]
pub mod lm_fbs {


pub enum NgramEntryOffset {}
#[derive(Copy, Clone, PartialEq)]

pub struct NgramEntry<'a> {
  pub _tab: ::flatbuffers::Table<'a>,
}

impl<'a> ::flatbuffers::Follow<'a> for NgramEntry<'a> {
  type Inner = NgramEntry<'a>;
  #[inline]
  unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
    Self { _tab: unsafe { ::flatbuffers::Table::new(buf, loc) } }
  }
}

impl<'a> NgramEntry<'a> {
  pub const VT_NGRAM: ::flatbuffers::VOffsetT = 4;
  pub const VT_COUNT: ::flatbuffers::VOffsetT = 6;

  #[inline]
  pub unsafe fn init_from_table(table: ::flatbuffers::Table<'a>) -> Self {
    NgramEntry { _tab: table }
  }
  #[allow(unused_mut)]
  pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr, A: ::flatbuffers::Allocator + 'bldr>(
    _fbb: &'mut_bldr mut ::flatbuffers::FlatBufferBuilder<'bldr, A>,
    args: &'args NgramEntryArgs<'args>
  ) -> ::flatbuffers::WIPOffset<NgramEntry<'bldr>> {
    let mut builder = NgramEntryBuilder::new(_fbb);
    builder.add_count(args.count);
    if let Some(x) = args.ngram { builder.add_ngram(x); }
    builder.finish()
  }


  #[inline]
  pub fn ngram(&self) -> ::flatbuffers::Vector<'a, ::flatbuffers::ForwardsUOffset<&'a str>> {
    // Safety:
    // Created from valid Table for this object
    // which contains a valid value in this slot
    unsafe { self._tab.get::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'a, ::flatbuffers::ForwardsUOffset<&'a str>>>>(NgramEntry::VT_NGRAM, None).unwrap()}
  }
  #[inline]
  pub fn count(&self) -> u64 {
    // Safety:
    // Created from valid Table for this object
    // which contains a valid value in this slot
    unsafe { self._tab.get::<u64>(NgramEntry::VT_COUNT, Some(0)).unwrap()}
  }
}

impl ::flatbuffers::Verifiable for NgramEntry<'_> {
  #[inline]
  fn run_verifier(
    v: &mut ::flatbuffers::Verifier, pos: usize
  ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> {
    v.visit_table(pos)?
     .visit_field::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'_, ::flatbuffers::ForwardsUOffset<&'_ str>>>>("ngram", Self::VT_NGRAM, true)?
     .visit_field::<u64>("count", Self::VT_COUNT, false)?
     .finish();
    Ok(())
  }
}
pub struct NgramEntryArgs<'a> {
    pub ngram: Option<::flatbuffers::WIPOffset<::flatbuffers::Vector<'a, ::flatbuffers::ForwardsUOffset<&'a str>>>>,
    pub count: u64,
}
impl<'a> Default for NgramEntryArgs<'a> {
  #[inline]
  fn default() -> Self {
    NgramEntryArgs {
      ngram: None, // required field
      count: 0,
    }
  }
}

pub struct NgramEntryBuilder<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> {
  fbb_: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>,
  start_: ::flatbuffers::WIPOffset<::flatbuffers::TableUnfinishedWIPOffset>,
}
impl<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> NgramEntryBuilder<'a, 'b, A> {
  #[inline]
  pub fn add_ngram(&mut self, ngram: ::flatbuffers::WIPOffset<::flatbuffers::Vector<'b , ::flatbuffers::ForwardsUOffset<&'b  str>>>) {
    self.fbb_.push_slot_always::<::flatbuffers::WIPOffset<_>>(NgramEntry::VT_NGRAM, ngram);
  }
  #[inline]
  pub fn add_count(&mut self, count: u64) {
    self.fbb_.push_slot::<u64>(NgramEntry::VT_COUNT, count, 0);
  }
  #[inline]
  pub fn new(_fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>) -> NgramEntryBuilder<'a, 'b, A> {
    let start = _fbb.start_table();
    NgramEntryBuilder {
      fbb_: _fbb,
      start_: start,
    }
  }
  #[inline]
  pub fn finish(self) -> ::flatbuffers::WIPOffset<NgramEntry<'a>> {
    let o = self.fbb_.end_table(self.start_);
    self.fbb_.required(o, NgramEntry::VT_NGRAM,"ngram");
    ::flatbuffers::WIPOffset::new(o.value())
  }
}

impl ::core::fmt::Debug for NgramEntry<'_> {
  fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result {
    let mut ds = f.debug_struct("NgramEntry");
      ds.field("ngram", &self.ngram());
      ds.field("count", &self.count());
      ds.finish()
  }
}
pub enum LmModelOffset {}
#[derive(Copy, Clone, PartialEq)]

pub struct LmModel<'a> {
  pub _tab: ::flatbuffers::Table<'a>,
}

impl<'a> ::flatbuffers::Follow<'a> for LmModel<'a> {
  type Inner = LmModel<'a>;
  #[inline]
  unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
    Self { _tab: unsafe { ::flatbuffers::Table::new(buf, loc) } }
  }
}

impl<'a> LmModel<'a> {
  pub const VT_ORDER: ::flatbuffers::VOffsetT = 4;
  pub const VT_SMOOTHING: ::flatbuffers::VOffsetT = 6;
  pub const VT_GAMMA: ::flatbuffers::VOffsetT = 8;
  pub const VT_VOCABULARY: ::flatbuffers::VOffsetT = 10;
  pub const VT_NGRAMS: ::flatbuffers::VOffsetT = 12;

  #[inline]
  pub unsafe fn init_from_table(table: ::flatbuffers::Table<'a>) -> Self {
    LmModel { _tab: table }
  }
  #[allow(unused_mut)]
  pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr, A: ::flatbuffers::Allocator + 'bldr>(
    _fbb: &'mut_bldr mut ::flatbuffers::FlatBufferBuilder<'bldr, A>,
    args: &'args LmModelArgs<'args>
  ) -> ::flatbuffers::WIPOffset<LmModel<'bldr>> {
    let mut builder = LmModelBuilder::new(_fbb);
    builder.add_gamma(args.gamma);
    if let Some(x) = args.ngrams { builder.add_ngrams(x); }
    if let Some(x) = args.vocabulary { builder.add_vocabulary(x); }
    if let Some(x) = args.smoothing { builder.add_smoothing(x); }
    builder.add_order(args.order);
    builder.finish()
  }


  #[inline]
  pub fn order(&self) -> u32 {
    // Safety:
    // Created from valid Table for this object
    // which contains a valid value in this slot
    unsafe { self._tab.get::<u32>(LmModel::VT_ORDER, Some(0)).unwrap()}
  }
  #[inline]
  pub fn smoothing(&self) -> &'a str {
    // Safety:
    // Created from valid Table for this object
    // which contains a valid value in this slot
    unsafe { self._tab.get::<::flatbuffers::ForwardsUOffset<&str>>(LmModel::VT_SMOOTHING, None).unwrap()}
  }
  #[inline]
  pub fn gamma(&self) -> f64 {
    // Safety:
    // Created from valid Table for this object
    // which contains a valid value in this slot
    unsafe { self._tab.get::<f64>(LmModel::VT_GAMMA, Some(0.0)).unwrap()}
  }
  #[inline]
  pub fn vocabulary(&self) -> ::flatbuffers::Vector<'a, ::flatbuffers::ForwardsUOffset<&'a str>> {
    // Safety:
    // Created from valid Table for this object
    // which contains a valid value in this slot
    unsafe { self._tab.get::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'a, ::flatbuffers::ForwardsUOffset<&'a str>>>>(LmModel::VT_VOCABULARY, None).unwrap()}
  }
  #[inline]
  pub fn ngrams(&self) -> ::flatbuffers::Vector<'a, ::flatbuffers::ForwardsUOffset<NgramEntry<'a>>> {
    // Safety:
    // Created from valid Table for this object
    // which contains a valid value in this slot
    unsafe { self._tab.get::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'a, ::flatbuffers::ForwardsUOffset<NgramEntry>>>>(LmModel::VT_NGRAMS, None).unwrap()}
  }
}

impl ::flatbuffers::Verifiable for LmModel<'_> {
  #[inline]
  fn run_verifier(
    v: &mut ::flatbuffers::Verifier, pos: usize
  ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> {
    v.visit_table(pos)?
     .visit_field::<u32>("order", Self::VT_ORDER, false)?
     .visit_field::<::flatbuffers::ForwardsUOffset<&str>>("smoothing", Self::VT_SMOOTHING, true)?
     .visit_field::<f64>("gamma", Self::VT_GAMMA, false)?
     .visit_field::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'_, ::flatbuffers::ForwardsUOffset<&'_ str>>>>("vocabulary", Self::VT_VOCABULARY, true)?
     .visit_field::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'_, ::flatbuffers::ForwardsUOffset<NgramEntry>>>>("ngrams", Self::VT_NGRAMS, true)?
     .finish();
    Ok(())
  }
}
pub struct LmModelArgs<'a> {
    pub order: u32,
    pub smoothing: Option<::flatbuffers::WIPOffset<&'a str>>,
    pub gamma: f64,
    pub vocabulary: Option<::flatbuffers::WIPOffset<::flatbuffers::Vector<'a, ::flatbuffers::ForwardsUOffset<&'a str>>>>,
    pub ngrams: Option<::flatbuffers::WIPOffset<::flatbuffers::Vector<'a, ::flatbuffers::ForwardsUOffset<NgramEntry<'a>>>>>,
}
impl<'a> Default for LmModelArgs<'a> {
  #[inline]
  fn default() -> Self {
    LmModelArgs {
      order: 0,
      smoothing: None, // required field
      gamma: 0.0,
      vocabulary: None, // required field
      ngrams: None, // required field
    }
  }
}

pub struct LmModelBuilder<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> {
  fbb_: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>,
  start_: ::flatbuffers::WIPOffset<::flatbuffers::TableUnfinishedWIPOffset>,
}
impl<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> LmModelBuilder<'a, 'b, A> {
  #[inline]
  pub fn add_order(&mut self, order: u32) {
    self.fbb_.push_slot::<u32>(LmModel::VT_ORDER, order, 0);
  }
  #[inline]
  pub fn add_smoothing(&mut self, smoothing: ::flatbuffers::WIPOffset<&'b  str>) {
    self.fbb_.push_slot_always::<::flatbuffers::WIPOffset<_>>(LmModel::VT_SMOOTHING, smoothing);
  }
  #[inline]
  pub fn add_gamma(&mut self, gamma: f64) {
    self.fbb_.push_slot::<f64>(LmModel::VT_GAMMA, gamma, 0.0);
  }
  #[inline]
  pub fn add_vocabulary(&mut self, vocabulary: ::flatbuffers::WIPOffset<::flatbuffers::Vector<'b , ::flatbuffers::ForwardsUOffset<&'b  str>>>) {
    self.fbb_.push_slot_always::<::flatbuffers::WIPOffset<_>>(LmModel::VT_VOCABULARY, vocabulary);
  }
  #[inline]
  pub fn add_ngrams(&mut self, ngrams: ::flatbuffers::WIPOffset<::flatbuffers::Vector<'b , ::flatbuffers::ForwardsUOffset<NgramEntry<'b >>>>) {
    self.fbb_.push_slot_always::<::flatbuffers::WIPOffset<_>>(LmModel::VT_NGRAMS, ngrams);
  }
  #[inline]
  pub fn new(_fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>) -> LmModelBuilder<'a, 'b, A> {
    let start = _fbb.start_table();
    LmModelBuilder {
      fbb_: _fbb,
      start_: start,
    }
  }
  #[inline]
  pub fn finish(self) -> ::flatbuffers::WIPOffset<LmModel<'a>> {
    let o = self.fbb_.end_table(self.start_);
    self.fbb_.required(o, LmModel::VT_SMOOTHING,"smoothing");
    self.fbb_.required(o, LmModel::VT_VOCABULARY,"vocabulary");
    self.fbb_.required(o, LmModel::VT_NGRAMS,"ngrams");
    ::flatbuffers::WIPOffset::new(o.value())
  }
}

impl ::core::fmt::Debug for LmModel<'_> {
  fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result {
    let mut ds = f.debug_struct("LmModel");
      ds.field("order", &self.order());
      ds.field("smoothing", &self.smoothing());
      ds.field("gamma", &self.gamma());
      ds.field("vocabulary", &self.vocabulary());
      ds.field("ngrams", &self.ngrams());
      ds.finish()
  }
}
#[inline]
/// Verifies that a buffer of bytes contains a `LmModel`
/// and returns it.
/// Note that verification is still experimental and may not
/// catch every error, or be maximally performant. For the
/// previous, unchecked, behavior use
/// `root_as_lm_model_unchecked`.
pub fn root_as_lm_model(buf: &[u8]) -> Result<LmModel<'_>, ::flatbuffers::InvalidFlatbuffer> {
  ::flatbuffers::root::<LmModel>(buf)
}
#[inline]
/// Verifies that a buffer of bytes contains a size prefixed
/// `LmModel` and returns it.
/// Note that verification is still experimental and may not
/// catch every error, or be maximally performant. For the
/// previous, unchecked, behavior use
/// `size_prefixed_root_as_lm_model_unchecked`.
pub fn size_prefixed_root_as_lm_model(buf: &[u8]) -> Result<LmModel<'_>, ::flatbuffers::InvalidFlatbuffer> {
  ::flatbuffers::size_prefixed_root::<LmModel>(buf)
}
#[inline]
/// Verifies, with the given options, that a buffer of bytes
/// contains a `LmModel` and returns it.
/// Note that verification is still experimental and may not
/// catch every error, or be maximally performant. For the
/// previous, unchecked, behavior use
/// `root_as_lm_model_unchecked`.
pub fn root_as_lm_model_with_opts<'b, 'o>(
  opts: &'o ::flatbuffers::VerifierOptions,
  buf: &'b [u8],
) -> Result<LmModel<'b>, ::flatbuffers::InvalidFlatbuffer> {
  ::flatbuffers::root_with_opts::<LmModel<'b>>(opts, buf)
}
#[inline]
/// Verifies, with the given verifier options, that a buffer of
/// bytes contains a size prefixed `LmModel` and returns
/// it. Note that verification is still experimental and may not
/// catch every error, or be maximally performant. For the
/// previous, unchecked, behavior use
/// `root_as_lm_model_unchecked`.
pub fn size_prefixed_root_as_lm_model_with_opts<'b, 'o>(
  opts: &'o ::flatbuffers::VerifierOptions,
  buf: &'b [u8],
) -> Result<LmModel<'b>, ::flatbuffers::InvalidFlatbuffer> {
  ::flatbuffers::size_prefixed_root_with_opts::<LmModel<'b>>(opts, buf)
}
#[inline]
/// Assumes, without verification, that a buffer of bytes contains a LmModel and returns it.
/// # Safety
/// Callers must trust the given bytes do indeed contain a valid `LmModel`.
pub unsafe fn root_as_lm_model_unchecked(buf: &[u8]) -> LmModel<'_> {
  unsafe { ::flatbuffers::root_unchecked::<LmModel>(buf) }
}
#[inline]
/// Assumes, without verification, that a buffer of bytes contains a size prefixed LmModel and returns it.
/// # Safety
/// Callers must trust the given bytes do indeed contain a valid size prefixed `LmModel`.
pub unsafe fn size_prefixed_root_as_lm_model_unchecked(buf: &[u8]) -> LmModel<'_> {
  unsafe { ::flatbuffers::size_prefixed_root_unchecked::<LmModel>(buf) }
}
#[inline]
pub fn finish_lm_model_buffer<'a, 'b, A: ::flatbuffers::Allocator + 'a>(
    fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>,
    root: ::flatbuffers::WIPOffset<LmModel<'a>>) {
  fbb.finish(root, None);
}

#[inline]
pub fn finish_size_prefixed_lm_model_buffer<'a, 'b, A: ::flatbuffers::Allocator + 'a>(fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>, root: ::flatbuffers::WIPOffset<LmModel<'a>>) {
  fbb.finish_size_prefixed(root, None);
}
}  // pub mod lm_fbs
}  // pub mod rustling