// automatically generated by the FlatBuffers compiler, do not modify
extern crate flatbuffers;

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

    use std::cmp::Ordering;
    use std::mem;

    extern crate flatbuffers;
    use self::flatbuffers::{EndianScalar, Follow};

    // struct Sample, aligned to 8
    #[repr(transparent)]
    #[derive(Clone, Copy, PartialEq)]
    pub struct Sample(pub [u8; 16]);
    impl Default for Sample {
        fn default() -> Self {
            Self([0; 16])
        }
    }
    impl std::fmt::Debug for Sample {
        fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
            f.debug_struct("Sample")
                .field("value", &self.value())
                .field("timestamp", &self.timestamp())
                .finish()
        }
    }

    impl flatbuffers::SimpleToVerifyInSlice for Sample {}
    impl flatbuffers::SafeSliceAccess for Sample {}
    impl<'a> flatbuffers::Follow<'a> for Sample {
        type Inner = &'a Sample;
        #[inline]
        fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
            <&'a Sample>::follow(buf, loc)
        }
    }
    impl<'a> flatbuffers::Follow<'a> for &'a Sample {
        type Inner = &'a Sample;
        #[inline]
        fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
            flatbuffers::follow_cast_ref::<Sample>(buf, loc)
        }
    }
    impl<'b> flatbuffers::Push for Sample {
        type Output = Sample;
        #[inline]
        fn push(&self, dst: &mut [u8], _rest: &[u8]) {
            let src = unsafe {
                ::std::slice::from_raw_parts(self as *const Sample as *const u8, Self::size())
            };
            dst.copy_from_slice(src);
        }
    }
    impl<'b> flatbuffers::Push for &'b Sample {
        type Output = Sample;

        #[inline]
        fn push(&self, dst: &mut [u8], _rest: &[u8]) {
            let src = unsafe {
                ::std::slice::from_raw_parts(*self as *const Sample as *const u8, Self::size())
            };
            dst.copy_from_slice(src);
        }
    }

    impl<'a> flatbuffers::Verifiable for Sample {
        #[inline]
        fn run_verifier(
            v: &mut flatbuffers::Verifier,
            pos: usize,
        ) -> Result<(), flatbuffers::InvalidFlatbuffer> {
            use self::flatbuffers::Verifiable;
            v.in_buffer::<Self>(pos)
        }
    }
    impl<'a> Sample {
        #[allow(clippy::too_many_arguments)]
        pub fn new(value: f64, timestamp: i64) -> Self {
            let mut s = Self([0; 16]);
            s.set_value(value);
            s.set_timestamp(timestamp);
            s
        }

        pub fn value(&self) -> f64 {
            let mut mem = core::mem::MaybeUninit::<f64>::uninit();
            unsafe {
                core::ptr::copy_nonoverlapping(
                    self.0[0..].as_ptr(),
                    mem.as_mut_ptr() as *mut u8,
                    core::mem::size_of::<f64>(),
                );
                mem.assume_init()
            }
            .from_little_endian()
        }

        pub fn set_value(&mut self, x: f64) {
            let x_le = x.to_little_endian();
            unsafe {
                core::ptr::copy_nonoverlapping(
                    &x_le as *const f64 as *const u8,
                    self.0[0..].as_mut_ptr(),
                    core::mem::size_of::<f64>(),
                );
            }
        }

        pub fn timestamp(&self) -> i64 {
            let mut mem = core::mem::MaybeUninit::<i64>::uninit();
            unsafe {
                core::ptr::copy_nonoverlapping(
                    self.0[8..].as_ptr(),
                    mem.as_mut_ptr() as *mut u8,
                    core::mem::size_of::<i64>(),
                );
                mem.assume_init()
            }
            .from_little_endian()
        }

        pub fn set_timestamp(&mut self, x: i64) {
            let x_le = x.to_little_endian();
            unsafe {
                core::ptr::copy_nonoverlapping(
                    &x_le as *const i64 as *const u8,
                    self.0[8..].as_mut_ptr(),
                    core::mem::size_of::<i64>(),
                );
            }
        }
    }

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

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

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

    impl<'a> Label<'a> {
        #[inline]
        pub fn init_from_table(table: flatbuffers::Table<'a>) -> Self {
            Label { _tab: table }
        }
        #[allow(unused_mut)]
        pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr>(
            _fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr>,
            args: &'args LabelArgs<'args>,
        ) -> flatbuffers::WIPOffset<Label<'bldr>> {
            let mut builder = LabelBuilder::new(_fbb);
            if let Some(x) = args.value {
                builder.add_value(x);
            }
            if let Some(x) = args.name {
                builder.add_name(x);
            }
            builder.finish()
        }

        pub const VT_NAME: flatbuffers::VOffsetT = 4;
        pub const VT_VALUE: flatbuffers::VOffsetT = 6;

        #[inline]
        pub fn name(&self) -> &'a str {
            self._tab
                .get::<flatbuffers::ForwardsUOffset<&str>>(Label::VT_NAME, None)
                .unwrap()
        }
        #[inline]
        pub fn value(&self) -> &'a str {
            self._tab
                .get::<flatbuffers::ForwardsUOffset<&str>>(Label::VT_VALUE, None)
                .unwrap()
        }
    }

    impl flatbuffers::Verifiable for Label<'_> {
        #[inline]
        fn run_verifier(
            v: &mut flatbuffers::Verifier,
            pos: usize,
        ) -> Result<(), flatbuffers::InvalidFlatbuffer> {
            use self::flatbuffers::Verifiable;
            v.visit_table(pos)?
                .visit_field::<flatbuffers::ForwardsUOffset<&str>>(&"name", Self::VT_NAME, true)?
                .visit_field::<flatbuffers::ForwardsUOffset<&str>>(&"value", Self::VT_VALUE, true)?
                .finish();
            Ok(())
        }
    }
    pub struct LabelArgs<'a> {
        pub name: Option<flatbuffers::WIPOffset<&'a str>>,
        pub value: Option<flatbuffers::WIPOffset<&'a str>>,
    }
    impl<'a> Default for LabelArgs<'a> {
        #[inline]
        fn default() -> Self {
            LabelArgs {
                name: None,  // required field
                value: None, // required field
            }
        }
    }
    pub struct LabelBuilder<'a: 'b, 'b> {
        fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a>,
        start_: flatbuffers::WIPOffset<flatbuffers::TableUnfinishedWIPOffset>,
    }
    impl<'a: 'b, 'b> LabelBuilder<'a, 'b> {
        #[inline]
        pub fn add_name(&mut self, name: flatbuffers::WIPOffset<&'b str>) {
            self.fbb_
                .push_slot_always::<flatbuffers::WIPOffset<_>>(Label::VT_NAME, name);
        }
        #[inline]
        pub fn add_value(&mut self, value: flatbuffers::WIPOffset<&'b str>) {
            self.fbb_
                .push_slot_always::<flatbuffers::WIPOffset<_>>(Label::VT_VALUE, value);
        }
        #[inline]
        pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a>) -> LabelBuilder<'a, 'b> {
            let start = _fbb.start_table();
            LabelBuilder {
                fbb_: _fbb,
                start_: start,
            }
        }
        #[inline]
        pub fn finish(self) -> flatbuffers::WIPOffset<Label<'a>> {
            let o = self.fbb_.end_table(self.start_);
            self.fbb_.required(o, Label::VT_NAME, "name");
            self.fbb_.required(o, Label::VT_VALUE, "value");
            flatbuffers::WIPOffset::new(o.value())
        }
    }

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

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

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

    impl<'a> Timeseries<'a> {
        #[inline]
        pub fn init_from_table(table: flatbuffers::Table<'a>) -> Self {
            Timeseries { _tab: table }
        }
        #[allow(unused_mut)]
        pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr>(
            _fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr>,
            args: &'args TimeseriesArgs<'args>,
        ) -> flatbuffers::WIPOffset<Timeseries<'bldr>> {
            let mut builder = TimeseriesBuilder::new(_fbb);
            if let Some(x) = args.samples {
                builder.add_samples(x);
            }
            if let Some(x) = args.labels {
                builder.add_labels(x);
            }
            builder.finish()
        }

        pub const VT_LABELS: flatbuffers::VOffsetT = 4;
        pub const VT_SAMPLES: flatbuffers::VOffsetT = 6;

        #[inline]
        pub fn labels(&self) -> flatbuffers::Vector<'a, flatbuffers::ForwardsUOffset<Label<'a>>> {
            self._tab
                .get::<flatbuffers::ForwardsUOffset<
                    flatbuffers::Vector<'a, flatbuffers::ForwardsUOffset<Label>>,
                >>(Timeseries::VT_LABELS, None)
                .unwrap()
        }
        #[inline]
        pub fn samples(&self) -> &'a [Sample] {
            self._tab
                .get::<flatbuffers::ForwardsUOffset<flatbuffers::Vector<'a, Sample>>>(
                    Timeseries::VT_SAMPLES,
                    None,
                )
                .map(|v| v.safe_slice())
                .unwrap()
        }
    }

    impl flatbuffers::Verifiable for Timeseries<'_> {
        #[inline]
        fn run_verifier(
            v: &mut flatbuffers::Verifier,
            pos: usize,
        ) -> Result<(), flatbuffers::InvalidFlatbuffer> {
            use self::flatbuffers::Verifiable;
            v.visit_table(pos)?
                .visit_field::<flatbuffers::ForwardsUOffset<
                    flatbuffers::Vector<'_, flatbuffers::ForwardsUOffset<Label>>,
                >>(&"labels", Self::VT_LABELS, true)?
                .visit_field::<flatbuffers::ForwardsUOffset<flatbuffers::Vector<'_, Sample>>>(
                    &"samples",
                    Self::VT_SAMPLES,
                    true,
                )?
                .finish();
            Ok(())
        }
    }
    pub struct TimeseriesArgs<'a> {
        pub labels: Option<
            flatbuffers::WIPOffset<
                flatbuffers::Vector<'a, flatbuffers::ForwardsUOffset<Label<'a>>>,
            >,
        >,
        pub samples: Option<flatbuffers::WIPOffset<flatbuffers::Vector<'a, Sample>>>,
    }
    impl<'a> Default for TimeseriesArgs<'a> {
        #[inline]
        fn default() -> Self {
            TimeseriesArgs {
                labels: None,  // required field
                samples: None, // required field
            }
        }
    }
    pub struct TimeseriesBuilder<'a: 'b, 'b> {
        fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a>,
        start_: flatbuffers::WIPOffset<flatbuffers::TableUnfinishedWIPOffset>,
    }
    impl<'a: 'b, 'b> TimeseriesBuilder<'a, 'b> {
        #[inline]
        pub fn add_labels(
            &mut self,
            labels: flatbuffers::WIPOffset<
                flatbuffers::Vector<'b, flatbuffers::ForwardsUOffset<Label<'b>>>,
            >,
        ) {
            self.fbb_
                .push_slot_always::<flatbuffers::WIPOffset<_>>(Timeseries::VT_LABELS, labels);
        }
        #[inline]
        pub fn add_samples(
            &mut self,
            samples: flatbuffers::WIPOffset<flatbuffers::Vector<'b, Sample>>,
        ) {
            self.fbb_
                .push_slot_always::<flatbuffers::WIPOffset<_>>(Timeseries::VT_SAMPLES, samples);
        }
        #[inline]
        pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a>) -> TimeseriesBuilder<'a, 'b> {
            let start = _fbb.start_table();
            TimeseriesBuilder {
                fbb_: _fbb,
                start_: start,
            }
        }
        #[inline]
        pub fn finish(self) -> flatbuffers::WIPOffset<Timeseries<'a>> {
            let o = self.fbb_.end_table(self.start_);
            self.fbb_.required(o, Timeseries::VT_LABELS, "labels");
            self.fbb_.required(o, Timeseries::VT_SAMPLES, "samples");
            flatbuffers::WIPOffset::new(o.value())
        }
    }

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

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

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

    impl<'a> WriteRequest<'a> {
        #[inline]
        pub fn init_from_table(table: flatbuffers::Table<'a>) -> Self {
            WriteRequest { _tab: table }
        }
        #[allow(unused_mut)]
        pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr>(
            _fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr>,
            args: &'args WriteRequestArgs<'args>,
        ) -> flatbuffers::WIPOffset<WriteRequest<'bldr>> {
            let mut builder = WriteRequestBuilder::new(_fbb);
            if let Some(x) = args.timeseries {
                builder.add_timeseries(x);
            }
            builder.finish()
        }

        pub const VT_TIMESERIES: flatbuffers::VOffsetT = 4;

        #[inline]
        pub fn timeseries(
            &self,
        ) -> flatbuffers::Vector<'a, flatbuffers::ForwardsUOffset<Timeseries<'a>>> {
            self._tab
                .get::<flatbuffers::ForwardsUOffset<
                    flatbuffers::Vector<'a, flatbuffers::ForwardsUOffset<Timeseries>>,
                >>(WriteRequest::VT_TIMESERIES, None)
                .unwrap()
        }
    }

    impl flatbuffers::Verifiable for WriteRequest<'_> {
        #[inline]
        fn run_verifier(
            v: &mut flatbuffers::Verifier,
            pos: usize,
        ) -> Result<(), flatbuffers::InvalidFlatbuffer> {
            use self::flatbuffers::Verifiable;
            v.visit_table(pos)?
                .visit_field::<flatbuffers::ForwardsUOffset<
                    flatbuffers::Vector<'_, flatbuffers::ForwardsUOffset<Timeseries>>,
                >>(&"timeseries", Self::VT_TIMESERIES, true)?
                .finish();
            Ok(())
        }
    }
    pub struct WriteRequestArgs<'a> {
        pub timeseries: Option<
            flatbuffers::WIPOffset<
                flatbuffers::Vector<'a, flatbuffers::ForwardsUOffset<Timeseries<'a>>>,
            >,
        >,
    }
    impl<'a> Default for WriteRequestArgs<'a> {
        #[inline]
        fn default() -> Self {
            WriteRequestArgs {
                timeseries: None, // required field
            }
        }
    }
    pub struct WriteRequestBuilder<'a: 'b, 'b> {
        fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a>,
        start_: flatbuffers::WIPOffset<flatbuffers::TableUnfinishedWIPOffset>,
    }
    impl<'a: 'b, 'b> WriteRequestBuilder<'a, 'b> {
        #[inline]
        pub fn add_timeseries(
            &mut self,
            timeseries: flatbuffers::WIPOffset<
                flatbuffers::Vector<'b, flatbuffers::ForwardsUOffset<Timeseries<'b>>>,
            >,
        ) {
            self.fbb_.push_slot_always::<flatbuffers::WIPOffset<_>>(
                WriteRequest::VT_TIMESERIES,
                timeseries,
            );
        }
        #[inline]
        pub fn new(
            _fbb: &'b mut flatbuffers::FlatBufferBuilder<'a>,
        ) -> WriteRequestBuilder<'a, 'b> {
            let start = _fbb.start_table();
            WriteRequestBuilder {
                fbb_: _fbb,
                start_: start,
            }
        }
        #[inline]
        pub fn finish(self) -> flatbuffers::WIPOffset<WriteRequest<'a>> {
            let o = self.fbb_.end_table(self.start_);
            self.fbb_
                .required(o, WriteRequest::VT_TIMESERIES, "timeseries");
            flatbuffers::WIPOffset::new(o.value())
        }
    }

    impl std::fmt::Debug for WriteRequest<'_> {
        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
            let mut ds = f.debug_struct("WriteRequest");
            ds.field("timeseries", &self.timeseries());
            ds.finish()
        }
    }
    #[inline]
    #[deprecated(since = "2.0.0", note = "Deprecated in favor of `root_as...` methods.")]
    pub fn get_root_as_write_request<'a>(buf: &'a [u8]) -> WriteRequest<'a> {
        unsafe { flatbuffers::root_unchecked::<WriteRequest<'a>>(buf) }
    }

    #[inline]
    #[deprecated(since = "2.0.0", note = "Deprecated in favor of `root_as...` methods.")]
    pub fn get_size_prefixed_root_as_write_request<'a>(buf: &'a [u8]) -> WriteRequest<'a> {
        unsafe { flatbuffers::size_prefixed_root_unchecked::<WriteRequest<'a>>(buf) }
    }

    #[inline]
    /// Verifies that a buffer of bytes contains a `WriteRequest`
    /// 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_write_request_unchecked`.
    pub fn root_as_write_request(
        buf: &[u8],
    ) -> Result<WriteRequest, flatbuffers::InvalidFlatbuffer> {
        flatbuffers::root::<WriteRequest>(buf)
    }
    #[inline]
    /// Verifies that a buffer of bytes contains a size prefixed
    /// `WriteRequest` 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_write_request_unchecked`.
    pub fn size_prefixed_root_as_write_request(
        buf: &[u8],
    ) -> Result<WriteRequest, flatbuffers::InvalidFlatbuffer> {
        flatbuffers::size_prefixed_root::<WriteRequest>(buf)
    }
    #[inline]
    /// Verifies, with the given options, that a buffer of bytes
    /// contains a `WriteRequest` 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_write_request_unchecked`.
    pub fn root_as_write_request_with_opts<'b, 'o>(
        opts: &'o flatbuffers::VerifierOptions,
        buf: &'b [u8],
    ) -> Result<WriteRequest<'b>, flatbuffers::InvalidFlatbuffer> {
        flatbuffers::root_with_opts::<WriteRequest<'b>>(opts, buf)
    }
    #[inline]
    /// Verifies, with the given verifier options, that a buffer of
    /// bytes contains a size prefixed `WriteRequest` 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_write_request_unchecked`.
    pub fn size_prefixed_root_as_write_request_with_opts<'b, 'o>(
        opts: &'o flatbuffers::VerifierOptions,
        buf: &'b [u8],
    ) -> Result<WriteRequest<'b>, flatbuffers::InvalidFlatbuffer> {
        flatbuffers::size_prefixed_root_with_opts::<WriteRequest<'b>>(opts, buf)
    }
    #[inline]
    /// Assumes, without verification, that a buffer of bytes contains a WriteRequest and returns it.
    /// # Safety
    /// Callers must trust the given bytes do indeed contain a valid `WriteRequest`.
    pub unsafe fn root_as_write_request_unchecked(buf: &[u8]) -> WriteRequest {
        flatbuffers::root_unchecked::<WriteRequest>(buf)
    }
    #[inline]
    /// Assumes, without verification, that a buffer of bytes contains a size prefixed WriteRequest and returns it.
    /// # Safety
    /// Callers must trust the given bytes do indeed contain a valid size prefixed `WriteRequest`.
    pub unsafe fn size_prefixed_root_as_write_request_unchecked(buf: &[u8]) -> WriteRequest {
        flatbuffers::size_prefixed_root_unchecked::<WriteRequest>(buf)
    }
    #[inline]
    pub fn finish_write_request_buffer<'a, 'b>(
        fbb: &'b mut flatbuffers::FlatBufferBuilder<'a>,
        root: flatbuffers::WIPOffset<WriteRequest<'a>>,
    ) {
        fbb.finish(root, None);
    }

    #[inline]
    pub fn finish_size_prefixed_write_request_buffer<'a, 'b>(
        fbb: &'b mut flatbuffers::FlatBufferBuilder<'a>,
        root: flatbuffers::WIPOffset<WriteRequest<'a>>,
    ) {
        fbb.finish_size_prefixed(root, None);
    }
} // pub mod write
