Skip to main content

qubit_codec/value/
value_codec_registration_source.rs

1// =============================================================================
2//    Copyright (c) 2026 Haixing Hu.
3//
4//    SPDX-License-Identifier: Apache-2.0
5// =============================================================================
6
7//! Value-codec registration source locations.
8
9/// Source location for one linked value-codec registration.
10#[derive(Clone, Copy, Debug, Eq, Ord, PartialEq, PartialOrd)]
11pub struct ValueCodecRegistrationSource {
12    crate_name: &'static str,
13    module_path: &'static str,
14    file: &'static str,
15    line: u32,
16}
17
18impl ValueCodecRegistrationSource {
19    /// Creates a source location captured by a registration macro.
20    #[doc(hidden)]
21    #[must_use]
22    pub const fn new(crate_name: &'static str, module_path: &'static str, file: &'static str, line: u32) -> Self {
23        Self {
24            crate_name,
25            module_path,
26            file,
27            line,
28        }
29    }
30
31    /// Returns the declaring crate name.
32    #[must_use]
33    pub const fn crate_name(&self) -> &'static str {
34        self.crate_name
35    }
36
37    /// Returns the declaring module path.
38    #[must_use]
39    pub const fn module_path(&self) -> &'static str {
40        self.module_path
41    }
42
43    /// Returns the source file path.
44    #[must_use]
45    pub const fn file(&self) -> &'static str {
46        self.file
47    }
48
49    /// Returns the one-based source line.
50    #[must_use]
51    pub const fn line(&self) -> u32 {
52        self.line
53    }
54}