#swiss #uid #data-structures #ustid #mwst #mehrwertsteuer

swiss_uid

A Rust implementation of the Swiss UID number based on the Swiss E-Government Standard eCH-0098:2021

3 stable releases

1.0.2 Aug 4, 2024
1.0.1 Jul 7, 2024
1.0.0 Jan 22, 2024

#85 in Finance

Download history 59/week @ 2024-07-29 61/week @ 2024-08-05 3/week @ 2024-08-12 15/week @ 2024-09-16 11/week @ 2024-09-23 35/week @ 2024-09-30

144 downloads per month

MIT license

19KB
364 lines

Swiss E-Government Standard eCH-0097: Datenstandard Unternehmensidentifikation

This library implements functionalities and data structures in accordance to the data standard eCH-0098:2021 5.2.0

Example usage

use swiss_uid::uid::SwissUid;

// Using the new function:
let uid = SwissUid::new("CHE-109.322.551").unwrap();
assert_eq!(format!("{:?}", uid), "CHE-109.322.55[1]".to_owned()); // Debug output
assert_eq!(format!("{}", uid), "CHE-109.322.551".to_owned()); // Display output
assert_eq!(uid.to_string(), "CHE-109.322.551".to_owned()); // Display output
assert_eq!(uid.to_string_mwst(), "CHE-109.322.551 MWST".to_owned());
assert_eq!(uid.to_string_hr(), "CHE-109.322.551 HR".to_owned());

// Parse a string directly:
let uid2: SwissUid = "CHE-109.322.551".parse().unwrap();
assert_eq!(uid2.to_string().len(), 15);

Dependencies

~760KB
~14K SLoC