1#![cfg_attr(any(doc, test), doc = include_str!("../README.md"))]
35#![cfg_attr(not(any(doc, test)), doc = env!("CARGO_PKG_NAME"))]
36#![doc(
37 html_logo_url = "https://raw.githubusercontent.com/tyranron\
38 /metrics-prometheus-rs\
39 /80bcffc2096f9ff213ec84833a9d8dd81a115cd5/logo.png",
40 html_favicon_url = "https://raw.githubusercontent.com/tyranron\
41 /metrics-prometheus-rs\
42 /80bcffc2096f9ff213ec84833a9d8dd81a115cd5/logo.png"
43)]
44#![deny(nonstandard_style, rustdoc::all, trivial_casts, trivial_numeric_casts)]
45#![forbid(non_ascii_idents, unsafe_code)]
46#![warn(
47 clippy::absolute_paths,
48 clippy::allow_attributes,
49 clippy::allow_attributes_without_reason,
50 clippy::as_conversions,
51 clippy::as_pointer_underscore,
52 clippy::as_ptr_cast_mut,
53 clippy::assertions_on_result_states,
54 clippy::branches_sharing_code,
55 clippy::cfg_not_test,
56 clippy::clear_with_drain,
57 clippy::clone_on_ref_ptr,
58 clippy::coerce_container_to_any,
59 clippy::collection_is_never_read,
60 clippy::create_dir,
61 clippy::dbg_macro,
62 clippy::debug_assert_with_mut_call,
63 clippy::decimal_literal_representation,
64 clippy::default_union_representation,
65 clippy::derive_partial_eq_without_eq,
66 clippy::doc_include_without_cfg,
67 clippy::doc_paragraphs_missing_punctuation,
68 clippy::empty_drop,
69 clippy::empty_structs_with_brackets,
70 clippy::equatable_if_let,
71 clippy::empty_enum_variants_with_brackets,
72 clippy::exit,
73 clippy::expect_used,
74 clippy::fallible_impl_from,
75 clippy::filetype_is_file,
76 clippy::float_cmp_const,
77 clippy::fn_to_numeric_cast_any,
78 clippy::get_unwrap,
79 clippy::if_then_some_else_none,
80 clippy::imprecise_flops,
81 clippy::infinite_loop,
82 clippy::iter_on_empty_collections,
83 clippy::iter_on_single_items,
84 clippy::iter_over_hash_type,
85 clippy::iter_with_drain,
86 clippy::large_include_file,
87 clippy::large_stack_frames,
88 clippy::let_underscore_untyped,
89 clippy::literal_string_with_formatting_args,
90 clippy::lossy_float_literal,
91 clippy::map_err_ignore,
92 clippy::map_with_unused_argument_over_ranges,
93 clippy::mem_forget,
94 clippy::missing_assert_message,
95 clippy::missing_asserts_for_indexing,
96 clippy::missing_const_for_fn,
97 clippy::missing_docs_in_private_items,
98 clippy::module_name_repetitions,
99 clippy::multiple_inherent_impl,
100 clippy::multiple_unsafe_ops_per_block,
101 clippy::mutex_atomic,
102 clippy::mutex_integer,
103 clippy::needless_collect,
104 clippy::needless_pass_by_ref_mut,
105 clippy::needless_raw_strings,
106 clippy::needless_type_cast,
107 clippy::non_zero_suggestions,
108 clippy::nonstandard_macro_braces,
109 clippy::option_if_let_else,
110 clippy::or_fun_call,
111 clippy::panic_in_result_fn,
112 clippy::partial_pub_fields,
113 clippy::pathbuf_init_then_push,
114 clippy::pedantic,
115 clippy::precedence_bits,
116 clippy::print_stderr,
117 clippy::print_stdout,
118 clippy::pub_without_shorthand,
119 clippy::rc_buffer,
120 clippy::rc_mutex,
121 clippy::read_zero_byte_vec,
122 clippy::redundant_clone,
123 clippy::redundant_test_prefix,
124 clippy::redundant_type_annotations,
125 clippy::renamed_function_params,
126 clippy::ref_patterns,
127 clippy::rest_pat_in_fully_bound_structs,
128 clippy::return_and_then,
129 clippy::same_name_method,
130 clippy::semicolon_inside_block,
131 clippy::set_contains_or_insert,
132 clippy::shadow_unrelated,
133 clippy::significant_drop_in_scrutinee,
134 clippy::significant_drop_tightening,
135 clippy::single_option_map,
136 clippy::str_to_string,
137 clippy::string_add,
138 clippy::string_lit_as_bytes,
139 clippy::string_lit_chars_any,
140 clippy::string_slice,
141 clippy::suboptimal_flops,
142 clippy::suspicious_operation_groupings,
143 clippy::suspicious_xor_used_as_pow,
144 clippy::tests_outside_test_module,
145 clippy::todo,
146 clippy::too_long_first_doc_paragraph,
147 clippy::trailing_empty_array,
148 clippy::transmute_undefined_repr,
149 clippy::trivial_regex,
150 clippy::try_err,
151 clippy::undocumented_unsafe_blocks,
152 clippy::unimplemented,
153 clippy::uninhabited_references,
154 clippy::unnecessary_safety_comment,
155 clippy::unnecessary_safety_doc,
156 clippy::unnecessary_self_imports,
157 clippy::unnecessary_struct_initialization,
158 clippy::unused_peekable,
159 clippy::unused_result_ok,
160 clippy::unused_trait_names,
161 clippy::unwrap_in_result,
162 clippy::unwrap_used,
163 clippy::use_debug,
164 clippy::use_self,
165 clippy::useless_let_if_seq,
166 clippy::verbose_file_reads,
167 clippy::volatile_composites,
168 clippy::while_float,
169 clippy::wildcard_enum_match_arm,
170 ambiguous_negative_literals,
171 closure_returning_async_block,
172 future_incompatible,
173 impl_trait_redundant_captures,
174 let_underscore_drop,
175 macro_use_extern_crate,
176 meta_variable_misuse,
177 missing_copy_implementations,
178 missing_debug_implementations,
179 missing_docs,
180 redundant_lifetimes,
181 rust_2018_idioms,
182 single_use_lifetimes,
183 unit_bindings,
184 unnameable_types,
185 unreachable_pub,
186 unstable_features,
187 unused,
188 variant_size_differences
189)]
190
191pub mod failure;
192pub mod metric;
193pub mod recorder;
194pub mod storage;
195
196#[doc(inline)]
197pub use self::{
198 metric::Metric,
199 recorder::{
200 Freezable as FreezableRecorder, Frozen as FrozenRecorder, Recorder,
201 },
202};
203
204pub fn try_install() -> Result<Recorder, metrics::SetRecorderError<Recorder>> {
213 Recorder::builder().try_build_and_install()
214}
215
216pub fn try_install_freezable()
225-> Result<FreezableRecorder, metrics::SetRecorderError<FreezableRecorder>> {
226 Recorder::builder().try_build_freezable_and_install()
227}
228
229#[expect( clippy::must_use_candidate,
239 reason = "`#[must_use]` is omitted here, to avoid forcing library users \
240 using the returned `Recorder` directly"
241)]
242pub fn install() -> Recorder {
243 Recorder::builder().build_and_install()
244}
245
246#[expect( clippy::must_use_candidate,
256 reason = "`#[must_use]` is omitted here, to avoid forcing library users \
257 using the returned `Recorder` directly"
258)]
259pub fn install_freezable() -> FreezableRecorder {
260 Recorder::builder().build_freezable_and_install()
261}