hyperlight-common 0.18.0

Hyperlight's components common to host and guest.
Documentation
// automatically generated by the FlatBuffers compiler, do not modify
// @generated
extern crate alloc;
extern crate flatbuffers;
use alloc::boxed::Box;
use alloc::string::{String, ToString};
use alloc::vec::Vec;
use core::cmp::Ordering;
use core::mem;

use self::flatbuffers::{EndianScalar, Follow};
use super::*;
pub enum hlexternalbytesOffset {}
#[derive(Copy, Clone, PartialEq)]

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

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

impl<'a> hlexternalbytes<'a> {
    pub const VT_LENGTH: flatbuffers::VOffsetT = 4;
    pub const VT_CHUNKED: flatbuffers::VOffsetT = 6;

    #[inline]
    pub unsafe fn init_from_table(table: flatbuffers::Table<'a>) -> Self {
        hlexternalbytes { _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 hlexternalbytesArgs,
    ) -> flatbuffers::WIPOffset<hlexternalbytes<'bldr>> {
        let mut builder = hlexternalbytesBuilder::new(_fbb);
        builder.add_length(args.length);
        builder.add_chunked(args.chunked);
        builder.finish()
    }

    #[inline]
    pub fn length(&self) -> u64 {
        // Safety:
        // Created from valid Table for this object
        // which contains a valid value in this slot
        unsafe {
            self._tab
                .get::<u64>(hlexternalbytes::VT_LENGTH, Some(0))
                .unwrap()
        }
    }
    #[inline]
    pub fn chunked(&self) -> bool {
        // Safety:
        // Created from valid Table for this object
        // which contains a valid value in this slot
        unsafe {
            self._tab
                .get::<bool>(hlexternalbytes::VT_CHUNKED, Some(false))
                .unwrap()
        }
    }
}

impl flatbuffers::Verifiable for hlexternalbytes<'_> {
    #[inline]
    fn run_verifier(
        v: &mut flatbuffers::Verifier,
        pos: usize,
    ) -> Result<(), flatbuffers::InvalidFlatbuffer> {
        use self::flatbuffers::Verifiable;
        v.visit_table(pos)?
            .visit_field::<u64>("length", Self::VT_LENGTH, false)?
            .visit_field::<bool>("chunked", Self::VT_CHUNKED, false)?
            .finish();
        Ok(())
    }
}
pub struct hlexternalbytesArgs {
    pub length: u64,
    pub chunked: bool,
}
impl<'a> Default for hlexternalbytesArgs {
    #[inline]
    fn default() -> Self {
        hlexternalbytesArgs {
            length: 0,
            chunked: false,
        }
    }
}

pub struct hlexternalbytesBuilder<'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> hlexternalbytesBuilder<'a, 'b, A> {
    #[inline]
    pub fn add_length(&mut self, length: u64) {
        self.fbb_
            .push_slot::<u64>(hlexternalbytes::VT_LENGTH, length, 0);
    }
    #[inline]
    pub fn add_chunked(&mut self, chunked: bool) {
        self.fbb_
            .push_slot::<bool>(hlexternalbytes::VT_CHUNKED, chunked, false);
    }
    #[inline]
    pub fn new(
        _fbb: &'b mut flatbuffers::FlatBufferBuilder<'a, A>,
    ) -> hlexternalbytesBuilder<'a, 'b, A> {
        let start = _fbb.start_table();
        hlexternalbytesBuilder {
            fbb_: _fbb,
            start_: start,
        }
    }
    #[inline]
    pub fn finish(self) -> flatbuffers::WIPOffset<hlexternalbytes<'a>> {
        let o = self.fbb_.end_table(self.start_);
        flatbuffers::WIPOffset::new(o.value())
    }
}

impl core::fmt::Debug for hlexternalbytes<'_> {
    fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
        let mut ds = f.debug_struct("hlexternalbytes");
        ds.field("length", &self.length());
        ds.field("chunked", &self.chunked());
        ds.finish()
    }
}