pub struct Pid(/* private fields */);Expand description
A BDEW Prüfidentifikator — the 5-digit numeric code that identifies a MaKo process family and is used to route inbound EDIFACT messages.
Valid range: 1..=99999. Zero is reserved and never a valid PID.
PIDs are 5 digits in BDEW documents (e.g. 55001, 44022, 17115).
§Construction
Pid::new— unchecked compile-time const (panics on out-of-range); use for known-valid literals only.Pid::from_u32— checked runtime parse; returnsNoneon invalid range.Pid::parse_str— parse from a decimal string (leading zeros allowed).
§Display
Pid formats as a zero-padded 5-digit string (55001, not 55_001).
§Example
use mako_engine::ids::Pid;
// Compile-time known literal:
const LIEFERANTENWECHSEL: Pid = Pid::new(55001);
// Runtime-checked parse:
let pid = Pid::from_u32(44022).expect("valid PID");
assert_eq!(pid.as_u32(), 44022);
assert_eq!(pid.to_string(), "44022");
// Out-of-range:
assert!(Pid::from_u32(0).is_none());
assert!(Pid::from_u32(100_000).is_none());Implementations§
Source§impl Pid
impl Pid
Sourcepub const fn new(value: u32) -> Self
pub const fn new(value: u32) -> Self
Create a Pid from a known-valid compile-time literal.
This is a const fn so it can be used in const context.
§Panics
Panics at compile time (or runtime in debug builds) if value == 0
or value > 99_999.
Sourcepub fn from_u32(value: u32) -> Option<Self>
pub fn from_u32(value: u32) -> Option<Self>
Parse a Pid from a runtime u32, returning None on invalid range.
Trait Implementations§
impl Copy for Pid
Source§impl<'de> Deserialize<'de> for Pid
impl<'de> Deserialize<'de> for Pid
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
impl Eq for Pid
Source§impl Ord for Pid
impl Ord for Pid
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
Source§impl PartialOrd for Pid
impl PartialOrd for Pid
impl StructuralPartialEq for Pid
Auto Trait Implementations§
impl Freeze for Pid
impl RefUnwindSafe for Pid
impl Send for Pid
impl Sync for Pid
impl Unpin for Pid
impl UnsafeUnpin for Pid
impl UnwindSafe for Pid
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more