| Crates.io | isomdl |
| lib.rs | isomdl |
| version | 0.2.0 |
| created_at | 2022-03-29 20:05:04.700485+00 |
| updated_at | 2025-10-09 13:39:48.553067+00 |
| description | ISO mDL implementation in Rust |
| homepage | https://github.com/spruceid/isomdl |
| repository | https://github.com/spruceid/isomdl |
| max_upload_size | |
| id | 558771 |
| size | 731,299 |
ISO/IEC DIS 18013-5 mDL implementation in Rust.
It is intended to be used in creating apps for devices and readers that can interact with each other to exchange mDL
data.
This crate contains a CLI tool. Run the --help command to see what actions you can perform.
cargo run -- --help
For example, you can get the namespaces and elements defined in an mDL:
cat test/stringified-mdl.txt | cargo run -- get-namespaces -
Here are some examples on how to use the library. You can see more in tests and read about in the dedicated README.
This example demonstrates a simulated device and reader interaction.
The reader requests the age_over_21 element, and the device responds with that value.
sequenceDiagram
autonumber
Note over Device: Initialize session
Device ->> Device: Create QR Code Engagement
Device -) + Reader: Send QR Code
Reader ->> - Reader: Establish Session
Reader -) + Device: Request age_over_21
Device -)- Reader: Send age_over_21
Reader ->> Reader: Process age_over_21
Note over Device, Reader: Session finished
QR code containing DeviceEngagement data, which includes its public key.mDL data, private key, and public key.QR code and creates a request for the age_over_21 element.age_over_21 element.age_over_21 element.There are several states through which the device goes during the interaction:
stateDiagram
state Device {
[*] --> SessionManagerInit: initialise
SessionManagerInit --> SessionManagerEngaged: qr_engagement
SessionManagerEngaged --> SessionManager: process_session_establishment
}
state SessionManagerInit {
[*] --> [*]
}
state SessionManagerEngaged {
[*] --> [*]
}
state Reader {
[*] --> [*]
}
state SessionManager {
[*] --> AwaitingRequest
AwaitingRequest --> Signing: prepare_response
Signing --> Signing: get_next_signature_payload
Signing --> ReadyToRespond: submit_next_signature
ReadyToRespond --> AwaitingRequest: retrieve_response
AwaitingRequest --> Signing: handle_request
}
User --> Device
SessionManagerInit --> Reader: qr_engagement
Reader --> SessionManagerEngaged: establish_session
ReadyToRespond --> Reader: handle_response
From the reader's perspective, the flow is simpler:
stateDiagram
state Device {
[*] --> [*]
}
state Reader {
SessionManager --> SessionManager: handle_response
}
User --> Device
Device --> Reader: qr_engagement
Reader --> Device: establish_session
Device --> Reader
Reader --> Device: new_request
You can see the full example in simulated_device_and_reader and a version that
uses State pattern, Arc and Mutex simulated_device_and_reader.