metrique-macro 0.1.5

Library for working with unit of work metrics - #[metrics] macro
Documentation
---
source: metrique-macro/src/lib.rs
expression: parsed_file
---
struct RequestMetrics {
    operation: &'static str,
}
const _: () = {
    #[deprecated(
        note = "You cannot use the character '.' with `prefix`. `prefix` will \"inflect\" to match the name scheme specified by `rename_all`. For example, it will change all delimiters to `-` for kebab case). If you want to match namestyle, use `prefix = \"X-\"`. If you want to preserve '.' in the final metric name use `exact_prefix = \"X.\". '.' is currently allowed when used with `prefix`, but in future versions, `exact_prefix` will be required"
    )]
    const _W: () = ();
    _W
};
#[doc(hidden)]
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,
}
const _: () = {
    #[expect(deprecated)]
    impl<NS: ::metrique::NameStyle> ::metrique::InflectableEntry<NS>
    for RequestMetricsEntry {
        fn write<'a>(&'a self, writer: &mut impl ::metrique::writer::EntryWriter<'a>) {
            ::metrique::writer::EntryWriter::value(
                writer,
                {
                    #[allow(non_camel_case_types)]
                    struct operationPreserve;
                    impl ::metrique::concat::ConstStr for operationPreserve {
                        const VAL: &'static str = "X.operation";
                    }
                    #[allow(non_camel_case_types)]
                    struct operationKebab;
                    impl ::metrique::concat::ConstStr for operationKebab {
                        const VAL: &'static str = "x-operation";
                    }
                    #[allow(non_camel_case_types)]
                    struct operationPascal;
                    impl ::metrique::concat::ConstStr for operationPascal {
                        const VAL: &'static str = "XOperation";
                    }
                    #[allow(non_camel_case_types)]
                    struct operationSnake;
                    impl ::metrique::concat::ConstStr for operationSnake {
                        const VAL: &'static str = "x_operation";
                    }
                    ::metrique::concat::const_str_value::<
                        <NS as ::metrique::NameStyle>::Inflect<
                            operationPreserve,
                            operationPascal,
                            operationSnake,
                            operationKebab,
                        >,
                    >()
                },
                &self.operation,
            );
        }
        fn sample_group(
            &self,
        ) -> impl ::std::iter::Iterator<
            Item = (::std::borrow::Cow<'static, str>, ::std::borrow::Cow<'static, str>),
        > {
            ::std::iter::empty()
        }
    }
};
impl metrique::CloseValue for RequestMetrics {
    type Closed = RequestMetricsEntry;
    fn close(self) -> Self::Closed {
        #[allow(deprecated)]
        RequestMetricsEntry {
            operation: metrique::CloseValue::close(self.operation),
        }
    }
}
type RequestMetricsGuard<Q = ::metrique::DefaultSink> = ::metrique::AppendAndCloseOnDrop<
    RequestMetrics,
    Q,
>;
type RequestMetricsHandle<Q = ::metrique::DefaultSink> = ::metrique::AppendAndCloseOnDropHandle<
    RequestMetrics,
    Q,
>;
impl RequestMetrics {
    ///Creates a 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)
    }
}