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

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

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

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

    #[deprecated(
        since = "2.0.0",
        note = "Use associated constants instead. This will no longer be generated in 2021."
    )]
    pub const ENUM_MIN_LANGUAGE: i8 = 0;
    #[deprecated(
        since = "2.0.0",
        note = "Use associated constants instead. This will no longer be generated in 2021."
    )]
    pub const ENUM_MAX_LANGUAGE: i8 = 0;
    #[deprecated(
        since = "2.0.0",
        note = "Use associated constants instead. This will no longer be generated in 2021."
    )]
    #[allow(non_camel_case_types)]
    pub const ENUM_VALUES_LANGUAGE: [Language; 1] = [Language::PromQL];

    #[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Default)]
    #[repr(transparent)]
    pub struct Language(pub i8);
    #[allow(non_upper_case_globals)]
    impl Language {
        pub const PromQL: Self = Self(0);

        pub const ENUM_MIN: i8 = 0;
        pub const ENUM_MAX: i8 = 0;
        pub const ENUM_VALUES: &'static [Self] = &[Self::PromQL];
        /// Returns the variant's name or "" if unknown.
        pub fn variant_name(self) -> Option<&'static str> {
            match self {
                Self::PromQL => Some("PromQL"),
                _ => None,
            }
        }
    }
    impl std::fmt::Debug for Language {
        fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
            if let Some(name) = self.variant_name() {
                f.write_str(name)
            } else {
                f.write_fmt(format_args!("<UNKNOWN {:?}>", self.0))
            }
        }
    }
    impl<'a> flatbuffers::Follow<'a> for Language {
        type Inner = Self;
        #[inline]
        fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
            let b = unsafe { flatbuffers::read_scalar_at::<i8>(buf, loc) };
            Self(b)
        }
    }

    impl flatbuffers::Push for Language {
        type Output = Language;
        #[inline]
        fn push(&self, dst: &mut [u8], _rest: &[u8]) {
            unsafe {
                flatbuffers::emplace_scalar::<i8>(dst, self.0);
            }
        }
    }

    impl flatbuffers::EndianScalar for Language {
        #[inline]
        fn to_little_endian(self) -> Self {
            let b = i8::to_le(self.0);
            Self(b)
        }
        #[inline]
        #[allow(clippy::wrong_self_convention)]
        fn from_little_endian(self) -> Self {
            let b = i8::from_le(self.0);
            Self(b)
        }
    }

    impl<'a> flatbuffers::Verifiable for Language {
        #[inline]
        fn run_verifier(
            v: &mut flatbuffers::Verifier,
            pos: usize,
        ) -> Result<(), flatbuffers::InvalidFlatbuffer> {
            use self::flatbuffers::Verifiable;
            i8::run_verifier(v, pos)
        }
    }

    impl flatbuffers::SimpleToVerifyInSlice for Language {}
    pub enum QueryRequestOffset {}
    #[derive(Copy, Clone, PartialEq)]

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

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

    impl<'a> QueryRequest<'a> {
        #[inline]
        pub fn init_from_table(table: flatbuffers::Table<'a>) -> Self {
            QueryRequest { _tab: table }
        }
        #[allow(unused_mut)]
        pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr>(
            _fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr>,
            args: &'args QueryRequestArgs<'args>,
        ) -> flatbuffers::WIPOffset<QueryRequest<'bldr>> {
            let mut builder = QueryRequestBuilder::new(_fbb);
            if let Some(x) = args.q {
                builder.add_q(x);
            }
            builder.add_language(args.language);
            builder.finish()
        }

        pub const VT_LANGUAGE: flatbuffers::VOffsetT = 4;
        pub const VT_Q: flatbuffers::VOffsetT = 6;

        #[inline]
        pub fn language(&self) -> Language {
            self._tab
                .get::<Language>(QueryRequest::VT_LANGUAGE, Some(Language::PromQL))
                .unwrap()
        }
        #[inline]
        pub fn q(&self) -> &'a str {
            self._tab
                .get::<flatbuffers::ForwardsUOffset<&str>>(QueryRequest::VT_Q, None)
                .unwrap()
        }
    }

    impl flatbuffers::Verifiable for QueryRequest<'_> {
        #[inline]
        fn run_verifier(
            v: &mut flatbuffers::Verifier,
            pos: usize,
        ) -> Result<(), flatbuffers::InvalidFlatbuffer> {
            use self::flatbuffers::Verifiable;
            v.visit_table(pos)?
                .visit_field::<Language>(&"language", Self::VT_LANGUAGE, false)?
                .visit_field::<flatbuffers::ForwardsUOffset<&str>>(&"q", Self::VT_Q, true)?
                .finish();
            Ok(())
        }
    }
    pub struct QueryRequestArgs<'a> {
        pub language: Language,
        pub q: Option<flatbuffers::WIPOffset<&'a str>>,
    }
    impl<'a> Default for QueryRequestArgs<'a> {
        #[inline]
        fn default() -> Self {
            QueryRequestArgs {
                language: Language::PromQL,
                q: None, // required field
            }
        }
    }
    pub struct QueryRequestBuilder<'a: 'b, 'b> {
        fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a>,
        start_: flatbuffers::WIPOffset<flatbuffers::TableUnfinishedWIPOffset>,
    }
    impl<'a: 'b, 'b> QueryRequestBuilder<'a, 'b> {
        #[inline]
        pub fn add_language(&mut self, language: Language) {
            self.fbb_
                .push_slot::<Language>(QueryRequest::VT_LANGUAGE, language, Language::PromQL);
        }
        #[inline]
        pub fn add_q(&mut self, q: flatbuffers::WIPOffset<&'b str>) {
            self.fbb_
                .push_slot_always::<flatbuffers::WIPOffset<_>>(QueryRequest::VT_Q, q);
        }
        #[inline]
        pub fn new(
            _fbb: &'b mut flatbuffers::FlatBufferBuilder<'a>,
        ) -> QueryRequestBuilder<'a, 'b> {
            let start = _fbb.start_table();
            QueryRequestBuilder {
                fbb_: _fbb,
                start_: start,
            }
        }
        #[inline]
        pub fn finish(self) -> flatbuffers::WIPOffset<QueryRequest<'a>> {
            let o = self.fbb_.end_table(self.start_);
            self.fbb_.required(o, QueryRequest::VT_Q, "q");
            flatbuffers::WIPOffset::new(o.value())
        }
    }

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

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

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

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