---
source: dial9-trace-format-derive/src/lib.rs
expression: "expand_to_string(quote!\n{\n    struct AllFieldTypes\n    {\n        #[traceevent(timestamp)] timestamp_ns: u64, a_u8: u8, b_u16: u16,\n        c_u32: u32, d_u64: u64, e_i64: i64, f_f64: f64, g_bool: bool,\n        h_string: String, i_bytes: Vec<u8>, j_interned: InternedString,\n        k_frames: StackFrames, l_map: Vec<(String, String)>,\n    }\n})"
---
#[derive(Debug, Clone)]
struct AllFieldTypesRef<'a> {
    pub timestamp_ns: u64,
    pub a_u8: <u8 as ::dial9_trace_format::TraceField>::Ref<'a>,
    pub b_u16: <u16 as ::dial9_trace_format::TraceField>::Ref<'a>,
    pub c_u32: <u32 as ::dial9_trace_format::TraceField>::Ref<'a>,
    pub d_u64: <u64 as ::dial9_trace_format::TraceField>::Ref<'a>,
    pub e_i64: <i64 as ::dial9_trace_format::TraceField>::Ref<'a>,
    pub f_f64: <f64 as ::dial9_trace_format::TraceField>::Ref<'a>,
    pub g_bool: <bool as ::dial9_trace_format::TraceField>::Ref<'a>,
    pub h_string: <String as ::dial9_trace_format::TraceField>::Ref<'a>,
    pub i_bytes: <Vec<u8> as ::dial9_trace_format::TraceField>::Ref<'a>,
    pub j_interned: <InternedString as ::dial9_trace_format::TraceField>::Ref<'a>,
    pub k_frames: <StackFrames as ::dial9_trace_format::TraceField>::Ref<'a>,
    pub l_map: <Vec<(String, String)> as ::dial9_trace_format::TraceField>::Ref<'a>,
}
impl ::dial9_trace_format::TraceEvent for AllFieldTypes {
    type Ref<'a> = AllFieldTypesRef<'a>;
    fn event_name() -> &'static str {
        "AllFieldTypes"
    }
    fn field_defs() -> Vec<::dial9_trace_format::schema::FieldDef> {
        vec![
            ::dial9_trace_format::schema::FieldDef::new("a_u8", < u8 as
            ::dial9_trace_format::TraceField > ::field_type(),),
            ::dial9_trace_format::schema::FieldDef::new("b_u16", < u16 as
            ::dial9_trace_format::TraceField > ::field_type(),),
            ::dial9_trace_format::schema::FieldDef::new("c_u32", < u32 as
            ::dial9_trace_format::TraceField > ::field_type(),),
            ::dial9_trace_format::schema::FieldDef::new("d_u64", < u64 as
            ::dial9_trace_format::TraceField > ::field_type(),),
            ::dial9_trace_format::schema::FieldDef::new("e_i64", < i64 as
            ::dial9_trace_format::TraceField > ::field_type(),),
            ::dial9_trace_format::schema::FieldDef::new("f_f64", < f64 as
            ::dial9_trace_format::TraceField > ::field_type(),),
            ::dial9_trace_format::schema::FieldDef::new("g_bool", < bool as
            ::dial9_trace_format::TraceField > ::field_type(),),
            ::dial9_trace_format::schema::FieldDef::new("h_string", < String as
            ::dial9_trace_format::TraceField > ::field_type(),),
            ::dial9_trace_format::schema::FieldDef::new("i_bytes", < Vec < u8 > as
            ::dial9_trace_format::TraceField > ::field_type(),),
            ::dial9_trace_format::schema::FieldDef::new("j_interned", < InternedString as
            ::dial9_trace_format::TraceField > ::field_type(),),
            ::dial9_trace_format::schema::FieldDef::new("k_frames", < StackFrames as
            ::dial9_trace_format::TraceField > ::field_type(),),
            ::dial9_trace_format::schema::FieldDef::new("l_map", < Vec < (String, String)
            > as ::dial9_trace_format::TraceField > ::field_type(),)
        ]
    }
    fn timestamp(&self) -> u64 {
        self.timestamp_ns
    }
    fn encode_fields<W: ::std::io::Write>(
        &self,
        enc: &mut ::dial9_trace_format::EventEncoder<'_, W>,
    ) -> ::std::io::Result<()> {
        <u8 as ::dial9_trace_format::TraceField>::encode(&self.a_u8, enc)?;
        <u16 as ::dial9_trace_format::TraceField>::encode(&self.b_u16, enc)?;
        <u32 as ::dial9_trace_format::TraceField>::encode(&self.c_u32, enc)?;
        <u64 as ::dial9_trace_format::TraceField>::encode(&self.d_u64, enc)?;
        <i64 as ::dial9_trace_format::TraceField>::encode(&self.e_i64, enc)?;
        <f64 as ::dial9_trace_format::TraceField>::encode(&self.f_f64, enc)?;
        <bool as ::dial9_trace_format::TraceField>::encode(&self.g_bool, enc)?;
        <String as ::dial9_trace_format::TraceField>::encode(&self.h_string, enc)?;
        <Vec<u8> as ::dial9_trace_format::TraceField>::encode(&self.i_bytes, enc)?;
        <InternedString as ::dial9_trace_format::TraceField>::encode(
            &self.j_interned,
            enc,
        )?;
        <StackFrames as ::dial9_trace_format::TraceField>::encode(&self.k_frames, enc)?;
        <Vec<
            (String, String),
        > as ::dial9_trace_format::TraceField>::encode(&self.l_map, enc)?;
        Ok(())
    }
    fn decode<'a>(
        timestamp_ns: Option<u64>,
        fields: &[::dial9_trace_format::types::FieldValueRef<'a>],
        field_defs: &[::dial9_trace_format::schema::FieldDef],
    ) -> Option<Self::Ref<'a>> {
        Some(AllFieldTypesRef {
            timestamp_ns: timestamp_ns?,
            a_u8: {
                let val = field_defs
                    .iter()
                    .zip(fields.iter())
                    .find(|(f, _)| f.name() == "a_u8")
                    .map(|(_, v)| v);
                match val {
                    Some(v) => <u8 as ::dial9_trace_format::TraceField>::decode_ref(v)?,
                    None => <u8 as ::dial9_trace_format::TraceField>::decode_missing()?,
                }
            },
            b_u16: {
                let val = field_defs
                    .iter()
                    .zip(fields.iter())
                    .find(|(f, _)| f.name() == "b_u16")
                    .map(|(_, v)| v);
                match val {
                    Some(v) => <u16 as ::dial9_trace_format::TraceField>::decode_ref(v)?,
                    None => <u16 as ::dial9_trace_format::TraceField>::decode_missing()?,
                }
            },
            c_u32: {
                let val = field_defs
                    .iter()
                    .zip(fields.iter())
                    .find(|(f, _)| f.name() == "c_u32")
                    .map(|(_, v)| v);
                match val {
                    Some(v) => <u32 as ::dial9_trace_format::TraceField>::decode_ref(v)?,
                    None => <u32 as ::dial9_trace_format::TraceField>::decode_missing()?,
                }
            },
            d_u64: {
                let val = field_defs
                    .iter()
                    .zip(fields.iter())
                    .find(|(f, _)| f.name() == "d_u64")
                    .map(|(_, v)| v);
                match val {
                    Some(v) => <u64 as ::dial9_trace_format::TraceField>::decode_ref(v)?,
                    None => <u64 as ::dial9_trace_format::TraceField>::decode_missing()?,
                }
            },
            e_i64: {
                let val = field_defs
                    .iter()
                    .zip(fields.iter())
                    .find(|(f, _)| f.name() == "e_i64")
                    .map(|(_, v)| v);
                match val {
                    Some(v) => <i64 as ::dial9_trace_format::TraceField>::decode_ref(v)?,
                    None => <i64 as ::dial9_trace_format::TraceField>::decode_missing()?,
                }
            },
            f_f64: {
                let val = field_defs
                    .iter()
                    .zip(fields.iter())
                    .find(|(f, _)| f.name() == "f_f64")
                    .map(|(_, v)| v);
                match val {
                    Some(v) => <f64 as ::dial9_trace_format::TraceField>::decode_ref(v)?,
                    None => <f64 as ::dial9_trace_format::TraceField>::decode_missing()?,
                }
            },
            g_bool: {
                let val = field_defs
                    .iter()
                    .zip(fields.iter())
                    .find(|(f, _)| f.name() == "g_bool")
                    .map(|(_, v)| v);
                match val {
                    Some(v) => <bool as ::dial9_trace_format::TraceField>::decode_ref(v)?,
                    None => <bool as ::dial9_trace_format::TraceField>::decode_missing()?,
                }
            },
            h_string: {
                let val = field_defs
                    .iter()
                    .zip(fields.iter())
                    .find(|(f, _)| f.name() == "h_string")
                    .map(|(_, v)| v);
                match val {
                    Some(v) => {
                        <String as ::dial9_trace_format::TraceField>::decode_ref(v)?
                    }
                    None => {
                        <String as ::dial9_trace_format::TraceField>::decode_missing()?
                    }
                }
            },
            i_bytes: {
                let val = field_defs
                    .iter()
                    .zip(fields.iter())
                    .find(|(f, _)| f.name() == "i_bytes")
                    .map(|(_, v)| v);
                match val {
                    Some(v) => {
                        <Vec<u8> as ::dial9_trace_format::TraceField>::decode_ref(v)?
                    }
                    None => {
                        <Vec<u8> as ::dial9_trace_format::TraceField>::decode_missing()?
                    }
                }
            },
            j_interned: {
                let val = field_defs
                    .iter()
                    .zip(fields.iter())
                    .find(|(f, _)| f.name() == "j_interned")
                    .map(|(_, v)| v);
                match val {
                    Some(v) => {
                        <InternedString as ::dial9_trace_format::TraceField>::decode_ref(
                            v,
                        )?
                    }
                    None => {
                        <InternedString as ::dial9_trace_format::TraceField>::decode_missing()?
                    }
                }
            },
            k_frames: {
                let val = field_defs
                    .iter()
                    .zip(fields.iter())
                    .find(|(f, _)| f.name() == "k_frames")
                    .map(|(_, v)| v);
                match val {
                    Some(v) => {
                        <StackFrames as ::dial9_trace_format::TraceField>::decode_ref(v)?
                    }
                    None => {
                        <StackFrames as ::dial9_trace_format::TraceField>::decode_missing()?
                    }
                }
            },
            l_map: {
                let val = field_defs
                    .iter()
                    .zip(fields.iter())
                    .find(|(f, _)| f.name() == "l_map")
                    .map(|(_, v)| v);
                match val {
                    Some(v) => {
                        <Vec<
                            (String, String),
                        > as ::dial9_trace_format::TraceField>::decode_ref(v)?
                    }
                    None => {
                        <Vec<
                            (String, String),
                        > as ::dial9_trace_format::TraceField>::decode_missing()?
                    }
                }
            },
        })
    }
}
