selium-atlas-protocol 0.2.3

Selium module for indexing and discovering resources with URIs
Documentation
// automatically generated by the FlatBuffers compiler, do not modify
// @generated
extern crate alloc;
use super::*;
pub enum UriOffset {}
#[derive(Copy, Clone, PartialEq)]

/// Canonical representation of a Selium URI.
pub struct Uri<'a> {
  pub _tab: ::flatbuffers::Table<'a>,
}

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

impl<'a> Uri<'a> {
  pub const VT_TENANT: ::flatbuffers::VOffsetT = 4;
  pub const VT_PATH: ::flatbuffers::VOffsetT = 6;
  pub const VT_APPLICATION: ::flatbuffers::VOffsetT = 8;
  pub const VT_SERVICE: ::flatbuffers::VOffsetT = 10;
  pub const VT_ENDPOINT: ::flatbuffers::VOffsetT = 12;

  #[inline]
  pub unsafe fn init_from_table(table: ::flatbuffers::Table<'a>) -> Self {
    Uri { _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 UriArgs<'args>
  ) -> ::flatbuffers::WIPOffset<Uri<'bldr>> {
    let mut builder = UriBuilder::new(_fbb);
    if let Some(x) = args.endpoint { builder.add_endpoint(x); }
    if let Some(x) = args.service { builder.add_service(x); }
    if let Some(x) = args.application { builder.add_application(x); }
    if let Some(x) = args.path { builder.add_path(x); }
    if let Some(x) = args.tenant { builder.add_tenant(x); }
    builder.finish()
  }


  /// Tenant portion extracted from the sel:// URI authority.
  #[inline]
  pub fn tenant(&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>>(Uri::VT_TENANT, None).unwrap()}
  }
  /// Optional path segments that precede the application component.
  #[inline]
  pub fn path(&self) -> Option<::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>>>>(Uri::VT_PATH, None)}
  }
  /// Application name including the ".app" suffix when present.
  #[inline]
  pub fn application(&self) -> Option<&'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>>(Uri::VT_APPLICATION, None)}
  }
  /// Service name resolved after the application component.
  #[inline]
  pub fn service(&self) -> Option<&'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>>(Uri::VT_SERVICE, None)}
  }
  /// Endpoint segment local to the service.
  #[inline]
  pub fn endpoint(&self) -> Option<&'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>>(Uri::VT_ENDPOINT, None)}
  }
}

impl ::flatbuffers::Verifiable for Uri<'_> {
  #[inline]
  fn run_verifier(
    v: &mut ::flatbuffers::Verifier, pos: usize
  ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> {
    v.visit_table(pos)?
     .visit_field::<::flatbuffers::ForwardsUOffset<&str>>("tenant", Self::VT_TENANT, true)?
     .visit_field::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'_, ::flatbuffers::ForwardsUOffset<&'_ str>>>>("path", Self::VT_PATH, false)?
     .visit_field::<::flatbuffers::ForwardsUOffset<&str>>("application", Self::VT_APPLICATION, false)?
     .visit_field::<::flatbuffers::ForwardsUOffset<&str>>("service", Self::VT_SERVICE, false)?
     .visit_field::<::flatbuffers::ForwardsUOffset<&str>>("endpoint", Self::VT_ENDPOINT, false)?
     .finish();
    Ok(())
  }
}
pub struct UriArgs<'a> {
    pub tenant: Option<::flatbuffers::WIPOffset<&'a str>>,
    pub path: Option<::flatbuffers::WIPOffset<::flatbuffers::Vector<'a, ::flatbuffers::ForwardsUOffset<&'a str>>>>,
    pub application: Option<::flatbuffers::WIPOffset<&'a str>>,
    pub service: Option<::flatbuffers::WIPOffset<&'a str>>,
    pub endpoint: Option<::flatbuffers::WIPOffset<&'a str>>,
}
impl<'a> Default for UriArgs<'a> {
  #[inline]
  fn default() -> Self {
    UriArgs {
      tenant: None, // required field
      path: None,
      application: None,
      service: None,
      endpoint: None,
    }
  }
}

pub struct UriBuilder<'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> UriBuilder<'a, 'b, A> {
  #[inline]
  pub fn add_tenant(&mut self, tenant: ::flatbuffers::WIPOffset<&'b  str>) {
    self.fbb_.push_slot_always::<::flatbuffers::WIPOffset<_>>(Uri::VT_TENANT, tenant);
  }
  #[inline]
  pub fn add_path(&mut self, path: ::flatbuffers::WIPOffset<::flatbuffers::Vector<'b , ::flatbuffers::ForwardsUOffset<&'b  str>>>) {
    self.fbb_.push_slot_always::<::flatbuffers::WIPOffset<_>>(Uri::VT_PATH, path);
  }
  #[inline]
  pub fn add_application(&mut self, application: ::flatbuffers::WIPOffset<&'b  str>) {
    self.fbb_.push_slot_always::<::flatbuffers::WIPOffset<_>>(Uri::VT_APPLICATION, application);
  }
  #[inline]
  pub fn add_service(&mut self, service: ::flatbuffers::WIPOffset<&'b  str>) {
    self.fbb_.push_slot_always::<::flatbuffers::WIPOffset<_>>(Uri::VT_SERVICE, service);
  }
  #[inline]
  pub fn add_endpoint(&mut self, endpoint: ::flatbuffers::WIPOffset<&'b  str>) {
    self.fbb_.push_slot_always::<::flatbuffers::WIPOffset<_>>(Uri::VT_ENDPOINT, endpoint);
  }
  #[inline]
  pub fn new(_fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>) -> UriBuilder<'a, 'b, A> {
    let start = _fbb.start_table();
    UriBuilder {
      fbb_: _fbb,
      start_: start,
    }
  }
  #[inline]
  pub fn finish(self) -> ::flatbuffers::WIPOffset<Uri<'a>> {
    let o = self.fbb_.end_table(self.start_);
    self.fbb_.required(o, Uri::VT_TENANT,"tenant");
    ::flatbuffers::WIPOffset::new(o.value())
  }
}

impl ::core::fmt::Debug for Uri<'_> {
  fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result {
    let mut ds = f.debug_struct("Uri");
      ds.field("tenant", &self.tenant());
      ds.field("path", &self.path());
      ds.field("application", &self.application());
      ds.field("service", &self.service());
      ds.field("endpoint", &self.endpoint());
      ds.finish()
  }
}
#[inline]
/// Verifies that a buffer of bytes contains a `Uri`
/// 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_uri_unchecked`.
pub fn root_as_uri(buf: &[u8]) -> Result<Uri<'_>, ::flatbuffers::InvalidFlatbuffer> {
  ::flatbuffers::root::<Uri>(buf)
}
#[inline]
/// Verifies that a buffer of bytes contains a size prefixed
/// `Uri` 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_uri_unchecked`.
pub fn size_prefixed_root_as_uri(buf: &[u8]) -> Result<Uri<'_>, ::flatbuffers::InvalidFlatbuffer> {
  ::flatbuffers::size_prefixed_root::<Uri>(buf)
}
#[inline]
/// Verifies, with the given options, that a buffer of bytes
/// contains a `Uri` 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_uri_unchecked`.
pub fn root_as_uri_with_opts<'b, 'o>(
  opts: &'o ::flatbuffers::VerifierOptions,
  buf: &'b [u8],
) -> Result<Uri<'b>, ::flatbuffers::InvalidFlatbuffer> {
  ::flatbuffers::root_with_opts::<Uri<'b>>(opts, buf)
}
#[inline]
/// Verifies, with the given verifier options, that a buffer of
/// bytes contains a size prefixed `Uri` 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_uri_unchecked`.
pub fn size_prefixed_root_as_uri_with_opts<'b, 'o>(
  opts: &'o ::flatbuffers::VerifierOptions,
  buf: &'b [u8],
) -> Result<Uri<'b>, ::flatbuffers::InvalidFlatbuffer> {
  ::flatbuffers::size_prefixed_root_with_opts::<Uri<'b>>(opts, buf)
}
#[inline]
/// Assumes, without verification, that a buffer of bytes contains a Uri and returns it.
/// # Safety
/// Callers must trust the given bytes do indeed contain a valid `Uri`.
pub unsafe fn root_as_uri_unchecked(buf: &[u8]) -> Uri<'_> {
  unsafe { ::flatbuffers::root_unchecked::<Uri>(buf) }
}
#[inline]
/// Assumes, without verification, that a buffer of bytes contains a size prefixed Uri and returns it.
/// # Safety
/// Callers must trust the given bytes do indeed contain a valid size prefixed `Uri`.
pub unsafe fn size_prefixed_root_as_uri_unchecked(buf: &[u8]) -> Uri<'_> {
  unsafe { ::flatbuffers::size_prefixed_root_unchecked::<Uri>(buf) }
}
#[inline]
pub fn finish_uri_buffer<'a, 'b, A: ::flatbuffers::Allocator + 'a>(
    fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>,
    root: ::flatbuffers::WIPOffset<Uri<'a>>) {
  fbb.finish(root, None);
}

#[inline]
pub fn finish_size_prefixed_uri_buffer<'a, 'b, A: ::flatbuffers::Allocator + 'a>(fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>, root: ::flatbuffers::WIPOffset<Uri<'a>>) {
  fbb.finish_size_prefixed(root, None);
}