# dmvs
A high-level asynchronous Rust client for a focused set of consumer-facing **ČÚZK DMVS SOAP** services.
The crate uses explicit integration/production environments, fixed HTTPS endpoints, mutual TLS with a PEM certificate chain and private key, an explicit requester subject, namespace-aware SOAP 1.1 decoding, correlated request UUIDs, typed service errors, bounded responses, and raw-preserving protocol values. Production is never the default.
The public geometry API uses `geo-types`; consumers can interoperate with the broader `geo` crate through its re-exported geometry types. Coordinates and CRS are preserved without implicit axis swaps or reprojection.
## Installation
```sh
cargo add dmvs
```
The crate is pre-1.0, so API changes may occur between minor releases. Rust 1.89 or newer is supported. The `reqwest`/rustls backend may require a supported C/CMake toolchain for its bundled native components.
## Supported services and operations
The supported surface is exactly **5 services and 18 official operations**. Each official operation below has one public `Client` method; explicitly named convenience helpers are listed separately. Partial services contain only the operations shown, not every operation in their WSDL.
The client does not infer registration, role, or legal eligibility; ČÚZK remains authoritative. R19 submissions and R49 inquiries can create server-side jobs. Non-public R19 is available to eligible downstream consumers, but supplying a requester status or evidence never establishes eligibility.
| Service | Eligibility and deployment notes | Official operation → public method |
| --- | --- | --- |
| **R18a — affected infrastructure respondents (1)** | Any registered subject. | `ctiVyjadrovatele` → `list_infrastructure_respondents` |
| **R18b — subject lookup (4)** | Any registered subject for these general-reader calls; excludes territory/scope searches requiring special roles. | `ctiSubjekt` → `read_subject`<br>`ctiSubjektDleIco` → `read_subject_by_organization_number`<br>`ctiSubjektyDleIdentifikace` → `search_subjects`<br>`ctiSubjektyDleCasti` → `list_infrastructure_part_subjects` |
| **R19 — custom-area DTM datasets (4)** | Public submission/result operations are included. Non-public operations require the applicable documented registration/eligibility, requester status, and evidence where required; the server decides eligibility. | `vyhotovVerejnouDatovouSadu` → `submit_public_custom_area_dataset`<br>`ctiVysledekVyhotovVerejnouDatovouSadu` → `read_public_custom_area_dataset_result`<br>`vyhotovNeverejnouDatovouSadu` → `submit_non_public_custom_area_dataset`<br>`ctiVysledekVyhotovNeverejnouDatovouSadu` → `read_non_public_custom_area_dataset_result` |
| **R24a — central code lists/configuration (5)** | Any registered subject. | `vylistujCiselniky` → `list_code_lists`<br>`ctiCiselnik` → `read_code_list`<br>`vylistujVerzeJvf` → `list_jvf_versions`<br>`ctiVerziJvf` → `read_jvf_version`<br>`vylistujCertifikatyIsDmvs` → `list_is_dmvs_certificates` |
| **R49 — infrastructure managers in a territory (4)** | Any registered subject for the selected central workflow. Documentation conflicts about `Design`/`Produkce` are recorded in `SCHEMAS.md`. | `zjistiUzemiSpravcuDti` → `submit_infrastructure_manager_inquiry`<br>`ctiVysledekZjistiUzemiSpravcuDti` → `read_infrastructure_manager_inquiry_result`<br>`ctiVysledekZjistiUzemiSpravcuDtiSeznamCastiDti` → `list_infrastructure_manager_inquiry_parts`<br>`ctiVysledekZjistiUzemiSpravcuDtiReport` → `read_infrastructure_manager_inquiry_report` |
For non-public R19, `NonPublicRequesterStatus::ApplicantByApplication` (`ZadatelDleZadosti`) requires genuine supporting evidence. Other genuine qualifying requester statuses use the same two non-public operations; they are not separate endpoints.
Convenience methods do not add protocol operations. The only convenience waits are `wait_for_public_custom_area_dataset`, `wait_for_non_public_custom_area_dataset`, and `wait_for_infrastructure_manager_inquiry`, which poll the corresponding existing R19 or R49 result operation. No other convenience pagination or polling helpers are provided.
### Environments
- `Environment::Integration` selects `https://dmvs-i.cuzk.gov.cz:8443/api/ws/v1`; INTEG accepts the documented PostSignum test or production certificate.
- `Environment::Production` selects `https://dmvs.cuzk.gov.cz:8443/api/ws/v1`; production requires an accepted registered client certificate. It must be selected explicitly and is never a default.
- Endpoint construction is not a claim of continuing deployment or authorization. See [SCHEMAS.md](SCHEMAS.md) for protocol provenance and documentation discrepancies.
## Quick start
Construction performs no network request. Both the TLS identity and requester subject are required; `.build()` fails if either is missing. This example lists JVF versions through R24a `vylistujVerzeJvf`:
```rust,no_run
use dmvs::{Client, Environment, SubjectId, TlsIdentity};
async fn example() -> Result<(), Box<dyn std::error::Error>> {
let certificate_chain = std::fs::read_to_string("certificate-chain.pem")?;
let private_key = std::fs::read_to_string("private-key.pem")?;
let subject_id = SubjectId::new(std::env::var("DMVS_SUBJECT")?)?;
let client = Client::builder(Environment::Integration)
.identity(TlsIdentity::from_pem(certificate_chain, private_key))
.subject_id(subject_id)
.build()?;
let versions = client.list_jvf_versions().await?;
for version in versions.value {
println!("{}: {}", version.version, version.description);
}
Ok(())
}
```
`Client::subject_id()` returns the configured `&SubjectId`. Use your operating system's secret store rather than embedding private keys in source, and do not log real subject identifiers. `TlsIdentity` supports an unencrypted RSA PKCS#8 PEM key and certificate chain; other rustls-compatible key encodings are accepted only when covered by tests.
### Requester-subject semantics
The configured subject is an explicit authenticated/requester identity for business payloads. It is **not inferred from the certificate** and is **not sent in HTTP or SOAP headers**. Mutual TLS still authenticates the transport independently.
- R19 public/non-public submissions and R49 inquiries automatically serialize the client subject into their requester/subject elements.
- R18a and R24a do not serialize the client subject.
- R18b lookup arguments remain per-call targets. In particular, `read_subject`'s `SubjectId` argument identifies the subject to look up; it is not replaced by the client's subject.
### Request constructors
- `InfrastructureManagerInquiryRequest::new(selector, identification)` creates an R49 inquiry; `.with_notification_email(...)` is optional.
- `PublicCustomAreaDatasetRequest::new(valid_on, contents, area, format)` creates a public R19 request; `.with_notification_email(...)` and `.with_regions(...)` are optional.
- `NonPublicCustomAreaDatasetRequest::new(status, evidence, contents, valid_on, area, format)` creates a non-public R19 request; `.with_notification_email(...)` and `.with_regions(...)` are optional. `ZadatelDleZadosti` requires evidence.
## Datasets, limits, and asynchronous recovery
### Content and request limits
- Public R19 uses `PublicCustomAreaDatasetContent::{Di, Zps}`. **`Ti` is not representable in the public request type.** Non-public R19 uses `NonPublicDatasetContent::{Di, Ti}`.
- Non-public requester status, purpose, optional legal reference, and conditionally required evidence are typed. `ZadatelDleZadosti` requires genuine evidence; supplying it never establishes eligibility, and other qualifying statuses are available through the same operation.
- R19 public/non-public custom areas and R49 area selectors have a **200 ha** (2,000,000 m²) maximum, checked as planar S-JTSK area where possible. Server-side validation still applies.
- R49 selects either one S-JTSK area or **1–400 RÚIAN parcel IDs**, never both.
- `PageRequest` is zero-based offset pagination with a limit of **1–250** and optional total count. R18a, R18b subject search, and R49 part-list calls retrieve only their requested page; no method auto-paginates. R49 prose is ambiguous between “250” and “fewer than 250”: the shared model permits 250, but use at most **249** when following the stricter wording.
- DMVS general and service-specific call quotas are **server-enforced**. The client's concurrency/byte limits are local resource controls, not a reliable distributed quota mechanism.
- `ClientBuilder::max_request_bytes` bounds the complete encoded SOAP/MTOM request during serialization, including MIME headers and attachments. The default is **64 MiB**, and zero is rejected.
### Polling and recovery
- R19 and R49 submissions are attempted exactly once. There are **no automatic retries**. An uncertain dispatch may already have created a server-side job; do not blindly resubmit after `SubmissionUncertain`.
- Persist the returned opaque `RequestId` securely. If a valid decoded response has an unexpected state but already contains an ID, `SubmissionUncertainWithRecovery` and `Error::recovery()` retain the complete response as redacted `SubmissionRecovery`, allowing recovery without another submission. Every submission also has a `submit_*_with_correlation_id` variant for explicit SOAP correlation; that UUID does not replace the server-issued request ID.
- Submission, one-shot result reads, waiting, R49 part/report reads, and downloads are independent; recovery by a persisted ID does not submit again.
- `WaitOptions` bounds the initial delay, total deadline, and fixed/backoff pacing. The default and minimum polling interval are **60 seconds**; shorter intervals are rejected. Waiting spawns no background task, does not outlive its deadline, never resubmits, and never downloads datasets or retrieves R49 part pages or the PDF implicitly.
- Every regional R19 state/rejection and every requested R49 result remains visible. Read each required page and result explicitly rather than assuming the first region or overall status represents all outcomes.
- R19 dataset results expose preparation and expiry metadata. Use `available_until` (`DostupneDo`) for each returned dataset; documented regional URLs normally expire after **ten days**, but the metadata—not a hard-coded lifetime—is authoritative.
## Files, MTOM, and downloads
Applicable R18a supporting files, R24a JVF files, and R49 PDF reports are decoded from inline base64 or **MTOM/XOP** responses with independent XML, MIME, decoded-file, and aggregate limits. Non-public R19 evidence uses bounded request-side MTOM with safe file names and either a caller-supplied raw checksum declaration or computed SHA-256 metadata. The evidence bytes are carried in a separate `application/octet-stream` MIME part, not inside the SOAP root XML.
Returned R19 URLs are never fetched implicitly. The separate `DatasetDownloader` performs only explicitly initiated HTTPS downloads, with redirects/retries disabled, configurable time/byte limits, buffered or caller-sink streaming, and optional size/checksum checks. It uses a separate credential-free HTTP client with ambient system proxies disabled and **never inherits or forwards the SOAP client's mTLS identity, headers, cookies, proxy credentials, or other credentials**.
A checksum is not a digital signature. Algorithms are verified only when explicitly declared and supported, or when the caller explicitly selects SHA-256; R49's bare 64-hex example is not assumed to be SHA-256. The crate does **not** provide an R29/R35 callback server, JVF/DGN/SHP/GPKG/PDF-internal parsing, GIS processing, archive extraction, or cryptographic signature verification/parsing.
## Examples
All examples compile offline. **Running them may contact DMVS, submit a job, or download a URL.** Read each file's header and use only authorized, non-sensitive inputs. Network examples use `examples/common/mod.rs`, which accepts PEM **contents** from `DMVS_CERTIFICATE_CHAIN` and `DMVS_PRIVATE_KEY` or PEM **paths** from `DMVS_CERTIFICATE_CHAIN_PEM` and `DMVS_PRIVATE_KEY_PEM`; `DMVS_SUBJECT` supplies the required subject. `DMVS_ENVIRONMENT` defaults to `integration`, and only exact `production` selects production.
| Example | Purpose |
| --- | --- |
| [`subject_lookup`](examples/subject_lookup.rs) | One R18b subject read without printing personal details. |
| [`jvf_versions`](examples/jvf_versions.rs) | R24a JVF-version discovery. |
| [`public_custom_area`](examples/public_custom_area.rs) | One public R19 DI submission and durable-ID handoff. |
| [`non_public_custom_area`](examples/non_public_custom_area.rs) | Non-public R19 DI/TI requester/evidence model. |
| [`dataset_recovery`](examples/dataset_recovery.rs) | R19 result recovery by persisted ID and explicit downloads. |
| [`dataset_download_to`](examples/dataset_download_to.rs) | Bounded, credential-free streaming to a temporary sink. |
| [`infrastructure_manager_inquiry`](examples/infrastructure_manager_inquiry.rs) | R49 submission, bounded wait, and separately opted-in report read. |
## Optional features
- `serde`: validated string serialization/deserialization for identifiers and correlation UUIDs.
- `tracing`: privacy-safe operation, environment, HTTP-status, and byte-count instrumentation. The application configures its own subscriber. Keys, XML, personal data, identifiers, polygons, URLs, and payloads are excluded.
## Safety and compatibility
- No redirects, automatic HTTP retries, arbitrary production endpoints, or disabled TLS verification.
- Every SOAP response is correlated to its request UUID and decoded with XML node/depth and byte limits.
- Server message text remains explicitly available in models but is redacted from normal error/debug output.
- Unknown states, severities, codes, and other protocol values are preserved rather than discarded.
- Normal tests and CI are offline and credential-free. Live tests are ignored by default and never part of routine checks.
## Live tests
The single separately authorized, read-only **R24a smoke target** is in `tests/live.rs`. It performs no submissions, polling, or downloads. Select the environment explicitly with `DMVS_ENVIRONMENT=integration` or `DMVS_ENVIRONMENT=production`; there is no default. INTEG loads the gitignored `.env.integ`, while production loads the gitignored `.env`. The selector and `DMVS_RUN_LIVE_TESTS=1` opt-in must be process environment variables. Credential values may come from the selected file or process environment:
- `DMVS_SUBJECT`: authorized test subject identifier required by client construction;
- `DMVS_PRIVATE_KEY`: unencrypted RSA PKCS#8 private-key **PEM contents**, not a path;
- `DMVS_CERTIFICATE_CHAIN`: client certificate-chain **PEM contents**, not a path.
Never commit `.env`, `.env.integ`, credentials, real subject identifiers, private records, or live response content. Normal test runs leave the live target ignored.
After explicit INTEG authorization, run:
```sh
DMVS_RUN_LIVE_TESTS=1 DMVS_ENVIRONMENT=integration cargo test --test live -- --ignored --test-threads=1
```
**Run production only after a separate, explicit production-test request; INTEG authorization is not production authorization.** Then run:
```sh
DMVS_RUN_LIVE_TESTS=1 DMVS_ENVIRONMENT=production cargo test --test live -- --ignored --test-threads=1
```
## Development
See [CONTRIBUTING.md](CONTRIBUTING.md) for the verification matrix and live-test safety, [SCHEMAS.md](SCHEMAS.md) for official protocol provenance and known documentation discrepancies, and [CHANGELOG.md](CHANGELOG.md) for changes.
The final public repository is [github.com/interaso/dmvs](https://github.com/interaso/dmvs). Development may use another remote before the first release; package metadata always refers to the final GitHub location.
## Official references
- [DMVS service documentation and WSDL/XSD packages](https://cuzk.gov.cz/DMVS/Popis-rozhrani/Popis-sluzeb.aspx)
- [Integration environments](https://cuzk.gov.cz/DMVS/Popis-rozhrani/Dokumentace-integracniho-prostredi.aspx)
- [Data-access overview](https://cuzk.gov.cz/DMVS/Poskytovani-dat.aspx)
## License
Licensed under the MIT License ([LICENSE](./LICENSE) or <https://opensource.org/licenses/MIT>).
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in this crate is licensed under the MIT License, without additional terms or conditions.