dmvs 0.1.1

Async high-level client for selected Czech ČÚZK DMVS SOAP services
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
use std::fmt;

use jiff::civil::Date;
use url::Url;

use crate::model::{Area, InputFile, RegionCode, XmlDateTime};
use crate::{Error, Result};

const MAX_CUSTOM_AREA_SQUARE_METRES: f64 = 2_000_000.0;

/// A dataset format, retaining values unknown to this crate version.
#[derive(Clone, Debug, Eq, Hash, PartialEq)]
#[non_exhaustive]
pub enum DatasetFormat {
    /// JVF (`JVF`).
    Jvf,
    /// DGN (`DGN`).
    Dgn,
    /// SHP (`SHP`).
    Shp,
    /// GPKG (`GPKG`).
    Gpkg,
    /// A future or otherwise unknown format, preserved exactly.
    Other(String),
}

impl DatasetFormat {
    /// Creates a format while preserving an unknown value exactly.
    pub fn from_raw(raw: impl Into<String>) -> Self {
        let raw = raw.into();
        match raw.as_str() {
            "JVF" => Self::Jvf,
            "DGN" => Self::Dgn,
            "SHP" => Self::Shp,
            "GPKG" => Self::Gpkg,
            _ => Self::Other(raw),
        }
    }

    /// Returns the official or untouched unknown format.
    pub fn as_str(&self) -> &str {
        match self {
            Self::Jvf => "JVF",
            Self::Dgn => "DGN",
            Self::Shp => "SHP",
            Self::Gpkg => "GPKG",
            Self::Other(raw) => raw,
        }
    }
}

/// Content accepted by public R19 custom-area dataset requests.
///
/// `Ti` is deliberately not representable. The following does not compile:
///
/// ```compile_fail
/// use dmvs::PublicCustomAreaDatasetContent;
/// let content = PublicCustomAreaDatasetContent::Ti;
/// ```
#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]
pub enum PublicCustomAreaDatasetContent {
    /// ZPS (`Zps`).
    Zps,
    /// DI (`Di`).
    Di,
}

impl PublicCustomAreaDatasetContent {
    /// Returns the exact XSD value.
    pub fn as_str(self) -> &'static str {
        match self {
            Self::Zps => "Zps",
            Self::Di => "Di",
        }
    }
}

/// Content accepted by non-public R19 custom-area dataset requests.
#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]
pub enum NonPublicDatasetContent {
    /// DI (`Di`).
    Di,
    /// TI (`Ti`), available only through the non-public workflow.
    Ti,
}

impl NonPublicDatasetContent {
    /// Returns the exact XSD value.
    pub fn as_str(self) -> &'static str {
        match self {
            Self::Di => "Di",
            Self::Ti => "Ti",
        }
    }
}

/// Processing state of one IS DTMK region, with raw preservation.
#[derive(Clone, Debug, Eq, Hash, PartialEq)]
#[non_exhaustive]
pub enum DatasetRegionState {
    /// Waiting to be sent (`CekaNaOdeslani`).
    WaitingForSubmission,
    /// Accepted by the region (`PrijatoKrajem`).
    AcceptedByRegion,
    /// Processed (`Zpracovano`).
    Completed,
    /// Failed (`Chyba`).
    Failed,
    /// A future or otherwise unknown state, preserved exactly.
    Other(String),
}

impl DatasetRegionState {
    /// Creates a state while preserving an unknown value exactly.
    pub fn from_raw(raw: impl Into<String>) -> Self {
        let raw = raw.into();
        match raw.as_str() {
            "CekaNaOdeslani" => Self::WaitingForSubmission,
            "PrijatoKrajem" => Self::AcceptedByRegion,
            "Zpracovano" => Self::Completed,
            "Chyba" => Self::Failed,
            _ => Self::Other(raw),
        }
    }

    /// Returns the official or untouched unknown state.
    pub fn as_str(&self) -> &str {
        match self {
            Self::WaitingForSubmission => "CekaNaOdeslani",
            Self::AcceptedByRegion => "PrijatoKrajem",
            Self::Completed => "Zpracovano",
            Self::Failed => "Chyba",
            Self::Other(raw) => raw,
        }
    }
}

/// Per-region issuance outcome, with raw preservation.
#[derive(Clone, Debug, Eq, Hash, PartialEq)]
#[non_exhaustive]
pub enum DatasetOutcome {
    /// Issuance was allowed (`VydejPovolen`).
    Allowed,
    /// Issuance was rejected (`VydejZamitnut`).
    Rejected,
    /// A future or otherwise unknown outcome, preserved exactly.
    Other(String),
}

impl DatasetOutcome {
    /// Creates an outcome while preserving an unknown value exactly.
    pub fn from_raw(raw: impl Into<String>) -> Self {
        let raw = raw.into();
        match raw.as_str() {
            "VydejPovolen" => Self::Allowed,
            "VydejZamitnut" => Self::Rejected,
            _ => Self::Other(raw),
        }
    }

    /// Returns the official or untouched unknown outcome.
    pub fn as_str(&self) -> &str {
        match self {
            Self::Allowed => "VydejPovolen",
            Self::Rejected => "VydejZamitnut",
            Self::Other(raw) => raw,
        }
    }
}

/// The `IdPodani` value returned with dataset results.
///
/// This is deliberately distinct from the durable asynchronous [`crate::RequestId`]
/// used to poll for those results.
#[derive(Clone, Eq, Hash, PartialEq)]
pub struct DatasetSubmissionId(String);

impl DatasetSubmissionId {
    /// Creates a non-empty identifier without interpreting its value.
    pub fn new(value: impl Into<String>) -> Result<Self> {
        let value = value.into();
        if value.is_empty()
            || value.len() > 256
            || value.trim() != value
            || value.chars().any(char::is_control)
        {
            return Err(Error::invalid_input(
                "dataset_submission_id",
                "expected a non-empty, trimmed string of at most 256 bytes without control characters",
            ));
        }
        Ok(Self(value))
    }

    /// Returns the identifier exactly as supplied by the service.
    pub fn as_str(&self) -> &str {
        &self.0
    }
}

impl fmt::Debug for DatasetSubmissionId {
    fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
        formatter.write_str("DatasetSubmissionId([REDACTED])")
    }
}

/// Requester statuses supported by the selected non-public workflow.
///
/// These values do not assert that a caller is eligible; the service remains
/// authoritative for registration and authorization checks.
#[derive(Clone, Debug, Eq, Hash, PartialEq)]
#[non_exhaustive]
pub enum NonPublicRequesterStatus {
    /// Owner, manager, or operator (`VlastnikSpravceProvozovatel`).
    OwnerManagerOperator,
    /// Authorized applicant (`OpravnenyZadatel`).
    AuthorizedApplicant,
    /// AZI (`Azi`).
    Azi,
    /// Applicant relying on an application (`ZadatelDleZadosti`); evidence is required.
    ApplicantByApplication,
    /// Owner of affected real estate (`VlastnikDotcenychNemovitosti`).
    AffectedPropertyOwner,
    /// A future or otherwise unknown status, preserved exactly.
    Other(String),
}

impl NonPublicRequesterStatus {
    /// Creates a status while preserving an unknown value exactly.
    pub fn from_raw(raw: impl Into<String>) -> Self {
        let raw = raw.into();
        match raw.as_str() {
            "VlastnikSpravceProvozovatel" => Self::OwnerManagerOperator,
            "OpravnenyZadatel" => Self::AuthorizedApplicant,
            "Azi" => Self::Azi,
            "ZadatelDleZadosti" => Self::ApplicantByApplication,
            "VlastnikDotcenychNemovitosti" => Self::AffectedPropertyOwner,
            _ => Self::Other(raw),
        }
    }

    /// Returns the official or untouched unknown status.
    pub fn as_str(&self) -> &str {
        match self {
            Self::OwnerManagerOperator => "VlastnikSpravceProvozovatel",
            Self::AuthorizedApplicant => "OpravnenyZadatel",
            Self::Azi => "Azi",
            Self::ApplicantByApplication => "ZadatelDleZadosti",
            Self::AffectedPropertyOwner => "VlastnikDotcenychNemovitosti",
            Self::Other(raw) => raw,
        }
    }
}

/// The required purpose choice in non-public supporting evidence.
#[derive(Clone, Eq, PartialEq)]
pub enum DatasetEvidencePurpose {
    /// A purpose code-list reference (`Ucel/Kod`).
    Code(String),
    /// Free-form purpose text (`UcelTextem`).
    Text(String),
}

impl fmt::Debug for DatasetEvidencePurpose {
    fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
        match self {
            Self::Code(_) => formatter.write_str("DatasetEvidencePurpose::Code([REDACTED])"),
            Self::Text(_) => formatter.write_str("DatasetEvidencePurpose::Text([REDACTED])"),
        }
    }
}

/// Purpose, optional legal reference, and required file for a non-public request.
#[derive(Clone, Eq, PartialEq)]
pub struct DatasetEvidence {
    /// Purpose code or free-form text.
    pub purpose: DatasetEvidencePurpose,
    /// Optional legal-reference code (`PravniPredpis/Kod`).
    pub legal_reference: Option<String>,
    /// Required supporting input file (`Priloha`).
    pub file: InputFile,
}

impl DatasetEvidence {
    /// Creates evidence with its required purpose and input file.
    pub fn new(purpose: DatasetEvidencePurpose, file: InputFile) -> Self {
        Self {
            purpose,
            legal_reference: None,
            file,
        }
    }

    /// Sets an optional legal-reference code.
    pub fn with_legal_reference(mut self, code: impl Into<String>) -> Self {
        self.legal_reference = Some(code.into());
        self
    }
}

impl fmt::Debug for DatasetEvidence {
    fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
        formatter
            .debug_struct("DatasetEvidence")
            .field("purpose", &self.purpose)
            .field(
                "legal_reference",
                &self.legal_reference.as_ref().map(|_| "[REDACTED]"),
            )
            .field("file", &"[REDACTED]")
            .finish()
    }
}

/// Validated input for R19 `vyhotovVerejnouDatovouSadu`.
///
/// The requester subject is supplied by [`crate::Client`].
#[derive(Clone, PartialEq)]
pub struct PublicCustomAreaDatasetRequest {
    pub(crate) valid_on: Date,
    pub(crate) contents: Vec<PublicCustomAreaDatasetContent>,
    pub(crate) regions: Option<Vec<RegionCode>>,
    pub(crate) area: Area,
    pub(crate) format: DatasetFormat,
    pub(crate) notification_email: Option<String>,
}

impl PublicCustomAreaDatasetRequest {
    /// Creates a request with nonempty content and an S-JTSK area of at most 200 ha.
    pub fn new(
        valid_on: Date,
        contents: Vec<PublicCustomAreaDatasetContent>,
        area: Area,
        format: DatasetFormat,
    ) -> Result<Self> {
        ensure_nonempty(contents.len(), "contents")?;
        area.ensure_maximum_s_jtsk_area(MAX_CUSTOM_AREA_SQUARE_METRES)?;
        Ok(Self {
            valid_on,
            contents,
            regions: None,
            area,
            format,
            notification_email: None,
        })
    }

    /// Selects a nonempty set of IS DTMK regions; without this, no `IsDtmk` is sent.
    pub fn with_regions(mut self, regions: Vec<RegionCode>) -> Result<Self> {
        ensure_nonempty(regions.len(), "regions")?;
        self.regions = Some(regions);
        Ok(self)
    }

    /// Sets the optional notification e-mail (`NotifikacniEmail`).
    pub fn with_notification_email(mut self, email: impl Into<String>) -> Self {
        self.notification_email = Some(email.into());
        self
    }
}

impl fmt::Debug for PublicCustomAreaDatasetRequest {
    fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
        formatter
            .debug_struct("PublicCustomAreaDatasetRequest")
            .field("valid_on", &self.valid_on)
            .field("contents", &self.contents)
            .field("region_count", &self.regions.as_ref().map(Vec::len))
            .field("area", &self.area)
            .field("format", &self.format)
            .field(
                "notification_email",
                &self.notification_email.as_ref().map(|_| "[REDACTED]"),
            )
            .finish()
    }
}

/// Validated input for R19 `vyhotovNeverejnouDatovouSadu`.
///
/// The requester subject is supplied by [`crate::Client`].
#[derive(Clone, PartialEq)]
pub struct NonPublicCustomAreaDatasetRequest {
    pub(crate) status: NonPublicRequesterStatus,
    pub(crate) evidence: Option<DatasetEvidence>,
    pub(crate) contents: Vec<NonPublicDatasetContent>,
    pub(crate) valid_on: Date,
    pub(crate) regions: Option<Vec<RegionCode>>,
    pub(crate) area: Area,
    pub(crate) format: DatasetFormat,
    pub(crate) notification_email: Option<String>,
}

impl NonPublicCustomAreaDatasetRequest {
    /// Creates a request with nonempty content and an S-JTSK area of at most 200 ha.
    ///
    /// Evidence is required for `ZadatelDleZadosti` and optional for every other
    /// status. Supplying or omitting it is not a local claim of eligibility.
    pub fn new(
        status: NonPublicRequesterStatus,
        evidence: Option<DatasetEvidence>,
        contents: Vec<NonPublicDatasetContent>,
        valid_on: Date,
        area: Area,
        format: DatasetFormat,
    ) -> Result<Self> {
        ensure_nonempty(contents.len(), "contents")?;
        ensure_evidence(&status, evidence.as_ref())?;
        area.ensure_maximum_s_jtsk_area(MAX_CUSTOM_AREA_SQUARE_METRES)?;
        Ok(Self {
            status,
            evidence,
            contents,
            valid_on,
            regions: None,
            area,
            format,
            notification_email: None,
        })
    }

    /// Selects a nonempty set of IS DTMK regions; without this, no `IsDtmk` is sent.
    pub fn with_regions(mut self, regions: Vec<RegionCode>) -> Result<Self> {
        ensure_nonempty(regions.len(), "regions")?;
        self.regions = Some(regions);
        Ok(self)
    }

    /// Sets the optional notification e-mail (`NotifikacniEmail`).
    pub fn with_notification_email(mut self, email: impl Into<String>) -> Self {
        self.notification_email = Some(email.into());
        self
    }
}

impl fmt::Debug for NonPublicCustomAreaDatasetRequest {
    fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
        formatter
            .debug_struct("NonPublicCustomAreaDatasetRequest")
            .field("status", &self.status)
            .field("evidence", &self.evidence)
            .field("contents", &self.contents)
            .field("valid_on", &self.valid_on)
            .field("region_count", &self.regions.as_ref().map(Vec::len))
            .field("area", &self.area)
            .field("format", &self.format)
            .field(
                "notification_email",
                &self.notification_email.as_ref().map(|_| "[REDACTED]"),
            )
            .finish()
    }
}

/// One custom-area dataset returned by R19.
#[derive(Clone, Eq, PartialEq)]
#[non_exhaustive]
pub struct CustomAreaDataset {
    /// Dataset format, including unknown future values.
    pub format: DatasetFormat,
    /// Preparation date and time (`Vyhotoveno`).
    pub prepared_at: XmlDateTime,
    /// Optional expiry date and time (`DostupneDo`).
    pub available_until: Option<XmlDateTime>,
    /// Declared dataset byte size (`Velikost`).
    pub size: u64,
    /// Dataset URL. It is never downloaded by response parsing.
    pub url: Url,
}

impl fmt::Debug for CustomAreaDataset {
    fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
        formatter
            .debug_struct("CustomAreaDataset")
            .field("format", &self.format)
            .field("prepared_at", &self.prepared_at)
            .field("available_until", &self.available_until)
            .field("size", &self.size)
            .field("url", &"[REDACTED]")
            .finish()
    }
}

/// One R19 regional result, including mixed outcome and optional dataset metadata.
#[derive(Clone, Eq, PartialEq)]
#[non_exhaustive]
pub struct CustomAreaDatasetRegionResult {
    /// IS DTMK region code.
    pub region: RegionCode,
    /// Raw-preserving regional state.
    pub state: DatasetRegionState,
    /// Optional allow/reject outcome.
    pub outcome: Option<DatasetOutcome>,
    /// Optional server-provided reason, redacted from debugging.
    pub reason: Option<String>,
    /// Optional dataset metadata.
    pub dataset: Option<CustomAreaDataset>,
}

impl fmt::Debug for CustomAreaDatasetRegionResult {
    fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
        formatter
            .debug_struct("CustomAreaDatasetRegionResult")
            .field("region", &self.region)
            .field("state", &self.state)
            .field("outcome", &self.outcome)
            .field("reason", &self.reason.as_ref().map(|_| "[REDACTED]"))
            .field("dataset", &self.dataset)
            .finish()
    }
}

/// Data returned by either R19 custom-area result operation.
#[derive(Clone, Debug, Eq, PartialEq)]
#[non_exhaustive]
pub struct CustomAreaDatasetResult {
    /// Result `IdPodani`, distinct from the asynchronous polling `RequestId`.
    pub submission_id: DatasetSubmissionId,
    /// Every regional result in service order.
    pub regions: Vec<CustomAreaDatasetRegionResult>,
}

fn ensure_nonempty(len: usize, field: &'static str) -> Result<()> {
    if len == 0 {
        Err(Error::invalid_input(
            field,
            "at least one value is required",
        ))
    } else {
        Ok(())
    }
}

fn ensure_evidence(
    status: &NonPublicRequesterStatus,
    evidence: Option<&DatasetEvidence>,
) -> Result<()> {
    if status.as_str() == "ZadatelDleZadosti" && evidence.is_none() {
        return Err(Error::invalid_input(
            "evidence",
            "ZadatelDleZadosti requires supporting evidence",
        ));
    }
    Ok(())
}

#[cfg(test)]
mod tests {
    use geo_types::{LineString, Polygon, coord};

    use super::*;

    fn date() -> Date {
        "2026-01-02".parse().unwrap()
    }

    fn area() -> Area {
        Area::s_jtsk(Polygon::new(
            LineString::from(vec![
                coord! { x: 0.0, y: 0.0 },
                coord! { x: 100.0, y: 0.0 },
                coord! { x: 100.0, y: 100.0 },
                coord! { x: 0.0, y: 100.0 },
                coord! { x: 0.0, y: 0.0 },
            ]),
            Vec::new(),
        ))
        .unwrap()
    }

    #[test]
    fn validates_content_regions_area_and_conditional_evidence() {
        assert!(
            PublicCustomAreaDatasetRequest::new(date(), Vec::new(), area(), DatasetFormat::Jvf,)
                .is_err()
        );
        let public = PublicCustomAreaDatasetRequest::new(
            date(),
            vec![PublicCustomAreaDatasetContent::Di],
            area(),
            DatasetFormat::Jvf,
        )
        .unwrap();
        assert!(public.with_regions(Vec::new()).is_err());

        assert!(
            NonPublicCustomAreaDatasetRequest::new(
                NonPublicRequesterStatus::ApplicantByApplication,
                None,
                vec![NonPublicDatasetContent::Ti],
                date(),
                area(),
                DatasetFormat::Shp,
            )
            .is_err()
        );
        assert!(
            NonPublicCustomAreaDatasetRequest::new(
                NonPublicRequesterStatus::Azi,
                None,
                vec![NonPublicDatasetContent::Ti],
                date(),
                area(),
                DatasetFormat::Shp,
            )
            .is_ok()
        );

        let exactly_200ha = Area::s_jtsk(Polygon::new(
            LineString::from(vec![
                coord! { x: 0.0, y: 0.0 },
                coord! { x: 2_000.0, y: 0.0 },
                coord! { x: 2_000.0, y: 1_000.0 },
                coord! { x: 0.0, y: 1_000.0 },
                coord! { x: 0.0, y: 0.0 },
            ]),
            Vec::new(),
        ))
        .unwrap();
        assert!(
            PublicCustomAreaDatasetRequest::new(
                date(),
                vec![PublicCustomAreaDatasetContent::Zps],
                exactly_200ha,
                DatasetFormat::Gpkg,
            )
            .is_ok()
        );

        let oversized = Area::s_jtsk(Polygon::new(
            LineString::from(vec![
                coord! { x: 0.0, y: 0.0 },
                coord! { x: 2_000.0, y: 0.0 },
                coord! { x: 2_000.0, y: 1_001.0 },
                coord! { x: 0.0, y: 1_001.0 },
                coord! { x: 0.0, y: 0.0 },
            ]),
            Vec::new(),
        ))
        .unwrap();
        assert!(
            PublicCustomAreaDatasetRequest::new(
                date(),
                vec![PublicCustomAreaDatasetContent::Zps],
                oversized,
                DatasetFormat::Gpkg,
            )
            .is_err()
        );
    }

    #[test]
    fn debug_redacts_email_purpose_and_evidence() {
        let evidence = DatasetEvidence::new(
            DatasetEvidencePurpose::Text("private-purpose".into()),
            InputFile::new("evidence.txt", b"private-file-content".as_slice()).unwrap(),
        )
        .with_legal_reference("private-legal-code");
        let request = NonPublicCustomAreaDatasetRequest::new(
            NonPublicRequesterStatus::ApplicantByApplication,
            Some(evidence),
            vec![NonPublicDatasetContent::Ti],
            date(),
            area(),
            DatasetFormat::Dgn,
        )
        .unwrap()
        .with_notification_email("private@example.invalid");
        let debug = format!("{request:?}");
        for private in [
            "private@example.invalid",
            "private-purpose",
            "private-legal-code",
            "private-file-content",
        ] {
            assert!(!debug.contains(private), "debug output contained {private}");
        }
    }

    #[test]
    fn raw_values_round_trip() {
        for (raw, known) in [
            ("JVF", DatasetFormat::Jvf),
            ("DGN", DatasetFormat::Dgn),
            ("SHP", DatasetFormat::Shp),
            ("GPKG", DatasetFormat::Gpkg),
        ] {
            assert_eq!(DatasetFormat::from_raw(raw), known);
        }
        let format = DatasetFormat::from_raw("FutureFormat");
        assert_eq!(format.as_str(), "FutureFormat");
        let state = DatasetRegionState::from_raw("FutureState");
        assert_eq!(state.as_str(), "FutureState");
        let outcome = DatasetOutcome::from_raw("FutureOutcome");
        assert_eq!(outcome.as_str(), "FutureOutcome");
        let status = NonPublicRequesterStatus::from_raw("FutureStatus");
        assert_eq!(status.as_str(), "FutureStatus");
    }
}