Expand description
ARS - Amtlicher Regionalschlüssel (German Regional Classification Key)
This crate provides functionality for working with the Amtlicher Regionalschlüssel (ARS), a 12-digit hierarchical identification system used in Germany to uniquely classify administrative regions from country level down to individual municipalities.
§Background
The ARS (originally called Regionalschlüssel or RS) was introduced in 1993/1994 as an extension to the 8-digit Amtlicher Gemeindeschlüssel (AGS - Official Municipality Key). The ARS integrates the AGS while adding four additional digits for encoding administrative associations (Gemeindeverbände).
For detailed information, see: Amtlicher Gemeindeschlüssel - Regionalschlüssel (Wikipedia)
§Structure
The 12-digit ARS code is composed of the following components:
┌─ Positions 1-2: Federal state (Bundesland) [0-16]
│ ┌─ Position 3: District (Regierungsbezirk) [0-9]
│ │ ┌─ Positions 4-5: County (Landkreis) [0-99]
│ │ │ ┌─ Positions 6-7: Admin Association V1 [0-99]
│ │ │ │ ┌─ Positions 8-9: Admin Association V2 [0-99]
│ │ │ │ │ ┌─ Positions 10-12: Municipality (Gemeinde) [0-999]
│ │ │ │ │ │
1 2 3 4 5 6 7 8 9 0 1 2§Hierarchical Levels
The ARS code represents a hierarchical administrative structure:
- 0: Country (Deutschland) - All zeros
- 1: State (Bundesland) - Federal state only
- 2: District (Regierungsbezirk) - Administrative district (where applicable)
- 3: County (Landkreis) - County or independent city
- 4: Admin Association (Verwaltungsgemeinschaft) - Municipal association
- 5: Municipality (Gemeinde) - Individual municipality
§Examples
use arscode::{ARSCode, ARSLevel, FederalState};
// Create an ARS code for Hamburg (state level)
let hamburg = ARSCode::new(2, 0, 0, 0, 0, 0).unwrap();
assert_eq!(hamburg.level(), ARSLevel::STATE);
assert_eq!(FederalState::from(hamburg), FederalState::Hamburg);
// Create an ARS code for a municipality
let municipality = ARSCode::new(5, 3, 15, 8, 4, 42).unwrap();
println!("{}", municipality); // Prints: 053158042042
assert_eq!(municipality.level(), ARSLevel::MUNICIPALITY);
// Parse from string
let ars: ARSCode = "053150804042".try_into().unwrap();
assert_eq!(ars, municipality);
// Navigate hierarchy
let parent = municipality.parent().unwrap(); // Administrative association
let grandparent = parent.parent().unwrap(); // County§Federal States
The 16 federal states are numbered 1-16 (0 represents Germany as a whole):
- Schleswig-Holstein
- Hamburg
- Lower Saxony (Niedersachsen)
- Bremen
- North Rhine-Westphalia (Nordrhein-Westfalen)
- Hesse (Hessen)
- Rhineland-Palatinate (Rheinland-Pfalz)
- Baden-Württemberg
- Bavaria (Bayern)
- Saarland
- Berlin
- Brandenburg
- Mecklenburg-Vorpommern
- Saxony (Sachsen)
- Saxony-Anhalt (Sachsen-Anhalt)
- Thuringia (Thüringen)
§Use Cases
- Statistical analysis and reporting
- Administrative region identification
- Data aggregation across hierarchical levels
- Finding common administrative parents
- Validating region identifiers
§Serde Support
When the serde feature is enabled, ARSCode can be serialized and deserialized.
§Localization
The lang_en and lang_de features control the language of displayed names:
lang_en: English names for federal stateslang_de: German names for federal states (default)
Modules§
Structs§
- ARSCode
- Represents a German ARS (Amtlicher Regionalschlüssel) code.
- ARSLevel
- Represents the hierarchical level of an ARS code.
Enums§
- ARSCode
Error - ARSLevel
Error - Error type for invalid ARS levels.
- Federal
State - Represents the 16 federal states of Germany and Germany as a whole.