pub struct Trigraph(/* private fields */);Expand description
A 3-character country trigraph (e.g., USA, GBR, AUS). Validated against CVE country code list at rule-check time.
The inner bytes are private; construction goes through Trigraph::try_new
which enforces ASCII-uppercase invariants so that Trigraph::as_str can
return a &str infallibly without panicking at runtime.
§Limitations
CAPCO also uses tetragraphs (NATO, FVEY, ACGU) and longer org codes
(AUSTRALIA_GROUP). These are present in the CVE TRIGRAPHS list but cannot
be represented by this type’s 3-byte constraint. A broader CountryCode
type is planned for a future version.
Implementations§
Source§impl Trigraph
impl Trigraph
Sourcepub const fn try_new(bytes: [u8; 3]) -> Option<Trigraph>
pub const fn try_new(bytes: [u8; 3]) -> Option<Trigraph>
Attempt to construct a trigraph from 3 bytes.
Returns None unless every byte is an ASCII uppercase letter
(A–Z), which is the invariant enforced by CAPCO for all valid
country/entity codes.
Sourcepub fn as_str(&self) -> &str
pub fn as_str(&self) -> &str
Return the trigraph as a string slice.
Infallible because construction via Trigraph::try_new (or the
Trigraph::USA constant) guarantees ASCII-uppercase bytes, which
are always valid UTF-8.