1use std::collections::BTreeMap;
2use std::path::PathBuf;
3
4use serde::{Deserialize, Serialize};
5use serde_json::Value;
6
7use crate::physical_identity::RetainedPhysicalIdentity;
8
9#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
10pub struct TemplateDescriptor {
11 pub(crate) id: String,
12 pub(crate) version: String,
13 pub(crate) name: String,
14}
15
16impl TemplateDescriptor {
17 pub fn id(&self) -> &str {
18 &self.id
19 }
20
21 pub fn version(&self) -> &str {
22 &self.version
23 }
24
25 pub fn name(&self) -> &str {
26 &self.name
27 }
28}
29
30#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
31pub struct TemplatePackage {
32 #[serde(rename = "$schema")]
33 pub(crate) schema: Option<String>,
34 pub(crate) protocol_version: String,
35 pub(crate) id: String,
36 pub(crate) version: String,
37 pub(crate) name: String,
38 pub(crate) description: Option<String>,
39 pub(crate) suggested_folderbase_kind: FolderbaseKind,
40 #[serde(default)]
41 pub(crate) questions: Vec<TemplateQuestion>,
42 pub(crate) artifacts: Vec<TemplateArtifact>,
43 #[serde(default)]
44 pub(crate) upgrade_edges: Vec<TemplateUpgradeEdge>,
45 #[serde(flatten)]
46 pub(crate) extensions: BTreeMap<String, Value>,
47}
48
49impl TemplatePackage {
50 pub fn protocol_version(&self) -> &str {
51 &self.protocol_version
52 }
53
54 pub fn id(&self) -> &str {
55 &self.id
56 }
57
58 pub fn version(&self) -> &str {
59 &self.version
60 }
61
62 pub fn name(&self) -> &str {
63 &self.name
64 }
65
66 pub fn questions(&self) -> &[TemplateQuestion] {
67 &self.questions
68 }
69}
70
71#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
72pub struct TemplateQuestion {
73 pub(crate) id: String,
74 pub(crate) prompt: String,
75 #[serde(default)]
76 pub(crate) answer_type: TemplateAnswerType,
77 #[serde(default)]
78 pub(crate) required: bool,
79 #[serde(flatten)]
80 pub(crate) extensions: BTreeMap<String, Value>,
81}
82
83impl TemplateQuestion {
84 pub fn id(&self) -> &str {
85 &self.id
86 }
87
88 pub fn prompt(&self) -> &str {
89 &self.prompt
90 }
91
92 pub fn answer_type(&self) -> TemplateAnswerType {
93 self.answer_type
94 }
95
96 pub fn required(&self) -> bool {
97 self.required
98 }
99}
100
101#[derive(Debug, Clone, Copy, Default, Serialize, Deserialize, PartialEq, Eq)]
102#[serde(rename_all = "snake_case")]
103pub enum TemplateAnswerType {
104 #[default]
105 Text,
106 Boolean,
107}
108
109#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
110#[serde(untagged)]
111pub enum TemplateAnswerValue {
112 Text(String),
113 Boolean(bool),
114}
115
116#[derive(Debug, Clone, Copy, Serialize, Deserialize, PartialEq, Eq)]
117#[serde(rename_all = "snake_case")]
118pub enum TemplateArtifactKind {
119 Directory,
120 Text,
121}
122
123#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
124pub(crate) struct TemplateArtifact {
125 pub(crate) target: PathBuf,
126 pub(crate) kind: TemplateArtifactKind,
127 pub(crate) content: Option<String>,
128 pub(crate) install: String,
129 #[serde(flatten)]
130 pub(crate) extensions: BTreeMap<String, Value>,
131}
132
133#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
134pub(crate) struct TemplateUpgradeEdge {
135 pub(crate) from: String,
136 pub(crate) to: String,
137 pub(crate) notes: Option<String>,
138 #[serde(flatten)]
139 pub(crate) extensions: BTreeMap<String, Value>,
140}
141
142#[derive(Debug, Serialize)]
143pub struct TemplateRenderPlan {
144 pub(crate) template_id: String,
145 pub(crate) template_version: String,
146 pub(crate) additions: Vec<PlannedTemplateAddition>,
147 pub(crate) existing_paths: Vec<PathBuf>,
148}
149
150impl TemplateRenderPlan {
151 pub fn template_id(&self) -> &str {
152 &self.template_id
153 }
154
155 pub fn template_version(&self) -> &str {
156 &self.template_version
157 }
158
159 pub fn additions(&self) -> &[PlannedTemplateAddition] {
160 &self.additions
161 }
162
163 pub fn existing_paths(&self) -> &[PathBuf] {
164 &self.existing_paths
165 }
166}
167
168#[derive(Debug, Serialize)]
169pub struct PlannedTemplateAddition {
170 pub(crate) path: PathBuf,
171 pub(crate) kind: TemplateArtifactKind,
172 pub(crate) content: Option<String>,
173}
174
175impl PlannedTemplateAddition {
176 pub fn path(&self) -> &std::path::Path {
177 &self.path
178 }
179
180 pub fn kind(&self) -> TemplateArtifactKind {
181 self.kind
182 }
183
184 pub fn content(&self) -> Option<&str> {
185 self.content.as_deref()
186 }
187}
188
189#[derive(Debug, Serialize)]
194pub struct TemplateExpansionPlan {
195 pub(crate) root: PathBuf,
196 pub(crate) folderbase_id: String,
197 pub(crate) template_id: String,
198 pub(crate) comparison_version: String,
199 pub(crate) comparison_source: TemplateComparisonSource,
200 pub(crate) comparison_application_id: Option<String>,
201 pub(crate) comparison_package_digest: TemplatePlanDigest,
202 pub(crate) template_version: String,
203 pub(crate) template_package_digest: TemplatePlanDigest,
204 pub(crate) additions: Vec<PlannedTemplateAddition>,
205 pub(crate) preserved_paths: Vec<PathBuf>,
206 pub(crate) blocked_paths: Vec<PathBuf>,
207 pub(crate) structural_changes: Vec<TemplateStructuralChange>,
208 pub(crate) plan_digest: TemplatePlanDigest,
209 pub(crate) manifest_sha256: String,
210 pub(crate) history_sha256: String,
211 pub(crate) preserved_preconditions: Vec<TemplateExpansionPrecondition>,
212 #[serde(skip_serializing)]
213 pub(crate) root_identity: RetainedPhysicalIdentity,
214}
215
216impl TemplateExpansionPlan {
217 pub fn template_id(&self) -> &str {
218 &self.template_id
219 }
220
221 pub fn comparison_version(&self) -> &str {
222 &self.comparison_version
223 }
224
225 pub fn template_version(&self) -> &str {
226 &self.template_version
227 }
228
229 pub fn additions(&self) -> &[PlannedTemplateAddition] {
230 &self.additions
231 }
232
233 pub fn preserved_paths(&self) -> &[PathBuf] {
234 &self.preserved_paths
235 }
236
237 pub fn blocked_paths(&self) -> &[PathBuf] {
238 &self.blocked_paths
239 }
240
241 pub fn structural_changes(&self) -> &[TemplateStructuralChange] {
242 &self.structural_changes
243 }
244
245 pub fn plan_digest(&self) -> &TemplatePlanDigest {
246 &self.plan_digest
247 }
248
249 pub fn is_noop(&self) -> bool {
250 self.template_version == self.comparison_version
251 && self.additions.is_empty()
252 && self.blocked_paths.is_empty()
253 && self.structural_changes.is_empty()
254 }
255}
256
257#[derive(Debug, Clone, Copy, Serialize, Deserialize, PartialEq, Eq, PartialOrd, Ord)]
258#[serde(rename_all = "snake_case")]
259pub enum TemplateStructuralChangeKind {
260 Downgrade,
261 Lineage,
262 UnsupportedTransition,
263}
264
265#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
266pub struct TemplateStructuralChange {
267 pub(crate) kind: TemplateStructuralChangeKind,
268 pub(crate) path: Option<PathBuf>,
269 pub(crate) reason: String,
270}
271
272impl TemplateStructuralChange {
273 pub fn kind(&self) -> TemplateStructuralChangeKind {
274 self.kind
275 }
276
277 pub fn path(&self) -> Option<&std::path::Path> {
278 self.path.as_deref()
279 }
280
281 pub fn reason(&self) -> &str {
282 &self.reason
283 }
284}
285
286#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
287pub struct TemplatePlanDigest {
288 pub(crate) algorithm: String,
289 pub(crate) digest: String,
290}
291
292impl TemplatePlanDigest {
293 pub fn algorithm(&self) -> &str {
294 &self.algorithm
295 }
296
297 pub fn digest(&self) -> &str {
298 &self.digest
299 }
300}
301
302#[derive(Debug, Serialize)]
303pub(crate) struct TemplateExpansionPrecondition {
304 pub(crate) path: PathBuf,
305 pub(crate) kind: TemplateArtifactKind,
306 pub(crate) sha256: Option<String>,
307 #[serde(skip_serializing)]
308 pub(crate) identity: RetainedPhysicalIdentity,
309}
310
311#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
312pub struct TemplateApplicationRecord {
313 #[serde(rename = "$schema")]
314 pub(crate) schema: String,
315 pub(crate) protocol_version: String,
316 pub(crate) id: String,
317 pub(crate) folderbase_id: String,
318 pub(crate) state: TemplateApplicationState,
319 pub(crate) template: AppliedTemplate,
320 pub(crate) comparison: TemplateApplicationComparison,
321 pub(crate) applied_at: String,
322 pub(crate) created_paths: Vec<TemplateApplicationCreatedPath>,
323 pub(crate) preserved_targets: Vec<TemplateApplicationPreservedTarget>,
324 pub(crate) plan_digest: TemplatePlanDigest,
325 pub(crate) record_digest: TemplatePlanDigest,
326}
327
328impl TemplateApplicationRecord {
329 pub fn id(&self) -> &str {
330 &self.id
331 }
332
333 pub fn folderbase_id(&self) -> &str {
334 &self.folderbase_id
335 }
336
337 pub fn state(&self) -> TemplateApplicationState {
338 self.state
339 }
340
341 pub fn template_id(&self) -> &str {
342 &self.template.id
343 }
344
345 pub fn template_version(&self) -> &str {
346 &self.template.version
347 }
348
349 pub fn comparison_version(&self) -> &str {
350 &self.comparison.version
351 }
352
353 pub fn applied_at(&self) -> &str {
354 &self.applied_at
355 }
356
357 pub fn created_paths(&self) -> &[TemplateApplicationCreatedPath] {
358 &self.created_paths
359 }
360
361 pub fn preserved_targets(&self) -> &[TemplateApplicationPreservedTarget] {
362 &self.preserved_targets
363 }
364
365 pub fn plan_digest(&self) -> &TemplatePlanDigest {
366 &self.plan_digest
367 }
368
369 pub fn record_digest(&self) -> &TemplatePlanDigest {
370 &self.record_digest
371 }
372}
373
374#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
375pub(crate) struct AppliedTemplate {
376 pub(crate) id: String,
377 pub(crate) version: String,
378 pub(crate) package_digest: TemplatePlanDigest,
379}
380
381#[derive(Debug, Clone, Copy, Serialize, Deserialize, PartialEq, Eq)]
382#[serde(rename_all = "snake_case")]
383pub enum TemplateApplicationState {
384 Verified,
385}
386
387#[derive(Debug, Clone, Copy, Serialize, Deserialize, PartialEq, Eq)]
388#[serde(rename_all = "snake_case")]
389pub enum TemplateComparisonSource {
390 Unmanaged,
391 Origin,
392 Application,
393}
394
395#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
396pub(crate) struct TemplateApplicationComparison {
397 pub(crate) source: TemplateComparisonSource,
398 pub(crate) version: String,
399 pub(crate) application_id: Option<String>,
400}
401
402#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
403pub struct TemplateApplicationCreatedPath {
404 pub(crate) path: PathBuf,
405 pub(crate) kind: TemplateArtifactKind,
406 pub(crate) bytes: Option<u64>,
407 pub(crate) sha256: Option<String>,
408}
409
410impl TemplateApplicationCreatedPath {
411 pub fn path(&self) -> &std::path::Path {
412 &self.path
413 }
414
415 pub fn kind(&self) -> TemplateArtifactKind {
416 self.kind
417 }
418
419 pub fn bytes(&self) -> Option<u64> {
420 self.bytes
421 }
422
423 pub fn sha256(&self) -> Option<&str> {
424 self.sha256.as_deref()
425 }
426}
427
428impl AsRef<std::path::Path> for TemplateApplicationCreatedPath {
429 fn as_ref(&self) -> &std::path::Path {
430 &self.path
431 }
432}
433
434#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
435pub struct TemplateApplicationPreservedTarget {
436 pub(crate) path: PathBuf,
437 pub(crate) kind: TemplateArtifactKind,
438 pub(crate) bytes: Option<u64>,
439 pub(crate) sha256: Option<String>,
440}
441
442impl TemplateApplicationPreservedTarget {
443 pub fn path(&self) -> &std::path::Path {
444 &self.path
445 }
446
447 pub fn kind(&self) -> TemplateArtifactKind {
448 self.kind
449 }
450
451 pub fn bytes(&self) -> Option<u64> {
452 self.bytes
453 }
454
455 pub fn sha256(&self) -> Option<&str> {
456 self.sha256.as_deref()
457 }
458}
459
460impl AsRef<std::path::Path> for TemplateApplicationPreservedTarget {
461 fn as_ref(&self) -> &std::path::Path {
462 &self.path
463 }
464}
465
466#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
467pub struct TemplateApplicationResult {
468 pub(crate) created_paths: Vec<PathBuf>,
469 pub(crate) preserved_paths: Vec<PathBuf>,
470 pub(crate) application_record: Option<PathBuf>,
471}
472
473impl TemplateApplicationResult {
474 pub fn created_paths(&self) -> &[PathBuf] {
475 &self.created_paths
476 }
477
478 pub fn preserved_paths(&self) -> &[PathBuf] {
479 &self.preserved_paths
480 }
481
482 pub fn application_record(&self) -> Option<&std::path::Path> {
483 self.application_record.as_deref()
484 }
485}
486
487#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
488pub struct InspectionReport {
489 pub root: PathBuf,
490 pub inventory: InventorySummary,
491 pub classified_paths: Vec<ClassifiedPath>,
492 pub git_repositories: Vec<PathBuf>,
493 pub context_files: Vec<PathBuf>,
494 pub boundary_hints: Vec<BoundaryHint>,
495 #[serde(default)]
496 pub reconstructable_trees: Vec<ReconstructableTree>,
497 #[serde(default)]
498 pub nested_folderbases: Vec<NestedFolderbaseBoundary>,
499 pub warnings: Vec<String>,
500}
501
502#[derive(Debug, Clone, Default, Serialize, Deserialize, PartialEq, Eq)]
503pub struct InventorySummary {
504 pub file_count: u64,
505 pub total_bytes: u64,
506 pub generated_file_count: u64,
507 #[serde(default)]
508 pub reconstructable_tree_count: u64,
509 pub secret_shaped_file_count: u64,
510 pub temporary_file_count: u64,
511 pub large_file_count: u64,
512 pub versioned_file_count: u64,
513}
514
515#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
516pub struct ClassifiedPath {
517 pub path: PathBuf,
518 pub classification: Classification,
519 pub reason: String,
520 pub bytes: u64,
521}
522
523#[derive(Debug, Clone, Copy, Serialize, Deserialize, PartialEq, Eq)]
524#[serde(rename_all = "snake_case")]
525pub enum Classification {
526 Generated,
527 SecretShaped,
528 Temporary,
529 Large,
530 Versioned,
531}
532
533#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
534pub struct BoundaryHint {
535 pub path: PathBuf,
536 pub kind: String,
537 pub reason: String,
538}
539
540#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
541pub struct ReconstructableTree {
542 #[serde(with = "crate::portable_wire_path::relative")]
543 pub path: PathBuf,
544}
545
546#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
547pub struct NestedFolderbaseBoundary {
548 #[serde(with = "crate::portable_wire_path::relative")]
549 pub path: PathBuf,
550 pub state: NestedFolderbaseState,
551}
552
553#[derive(Debug, Clone, Copy, Serialize, Deserialize, PartialEq, Eq)]
554#[serde(rename_all = "snake_case")]
555pub enum NestedFolderbaseState {
556 Unchecked,
557}
558
559#[derive(Debug, Clone, Copy, Default, Serialize, Deserialize, PartialEq, Eq)]
560#[serde(rename_all = "snake_case")]
561pub enum FolderbaseKind {
562 Person,
563 Organization,
564 Engagement,
565 #[default]
566 Project,
567 Customer,
568 Temporary,
569 Custom,
570}
571
572#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
573pub struct InitializationOptions {
574 pub name: Option<String>,
575 pub kind: FolderbaseKind,
576 pub create_agent_adapters: bool,
577}
578
579impl Default for InitializationOptions {
580 fn default() -> Self {
581 Self {
582 name: None,
583 kind: FolderbaseKind::Project,
584 create_agent_adapters: false,
585 }
586 }
587}
588
589#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
592pub struct InitializationPlanDigest {
593 pub(crate) algorithm: String,
594 pub(crate) digest: String,
595}
596
597impl InitializationPlanDigest {
598 pub fn parse_sha256(digest: impl Into<String>) -> crate::Result<Self> {
599 let digest = digest.into();
600 if !Self::is_valid_sha256(&digest) {
601 return Err(crate::FolderbaseError::InvalidInitializationPlanDigest);
602 }
603 Ok(Self {
604 algorithm: "sha256".to_owned(),
605 digest,
606 })
607 }
608
609 pub fn algorithm(&self) -> &str {
610 &self.algorithm
611 }
612
613 pub fn digest(&self) -> &str {
614 &self.digest
615 }
616
617 pub(crate) fn validate(&self) -> crate::Result<()> {
618 if self.algorithm != "sha256" || !Self::is_valid_sha256(&self.digest) {
619 return Err(crate::FolderbaseError::InvalidInitializationPlanDigest);
620 }
621 Ok(())
622 }
623
624 fn is_valid_sha256(digest: &str) -> bool {
625 digest.len() == 64
626 && digest
627 .bytes()
628 .all(|byte| byte.is_ascii_digit() || (b'a'..=b'f').contains(&byte))
629 }
630}
631
632#[derive(Clone)]
633pub(crate) enum InitializationRequest {
634 Ordinary {
635 options: InitializationOptions,
636 },
637 Template {
638 options: InitializationOptions,
639 package: Box<TemplatePackage>,
640 answers: BTreeMap<String, TemplateAnswerValue>,
641 },
642}
643
644impl std::fmt::Debug for InitializationRequest {
645 fn fmt(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
646 match self {
647 Self::Ordinary { options } => formatter
648 .debug_struct("Ordinary")
649 .field("options", options)
650 .finish(),
651 Self::Template {
652 options,
653 package,
654 answers,
655 } => formatter
656 .debug_struct("Template")
657 .field("options", options)
658 .field("template_id", &package.id)
659 .field("template_version", &package.version)
660 .field("answer_ids", &answers.keys().collect::<Vec<_>>())
661 .finish(),
662 }
663 }
664}
665
666#[derive(Debug, Clone, PartialEq, Eq)]
667pub(crate) struct InitializationDestinationEntry {
668 pub(crate) path: PathBuf,
669 pub(crate) kind: InitializationDestinationKind,
670}
671
672#[derive(Debug, Clone, Copy, PartialEq, Eq)]
673pub(crate) enum InitializationDestinationKind {
674 Directory,
675 File,
676 Symlink,
677 ReconstructableDirectory,
678 GitMetadata,
679 NestedFolderbase,
680 Other,
681}
682
683#[derive(Debug, Serialize)]
688pub struct InitializationPlan {
689 pub(crate) root: PathBuf,
690 pub(crate) folderbase_id: String,
691 pub(crate) folderbase_name: String,
692 pub(crate) folderbase_kind: FolderbaseKind,
693 pub(crate) directories: Vec<PlannedDirectory>,
694 pub(crate) writes: Vec<PlannedWrite>,
695 pub(crate) template_preconditions: Vec<TemplateArtifactPrecondition>,
696 pub(crate) preserved_paths: Vec<PreservedPath>,
697 pub(crate) warnings: Vec<String>,
698 pub(crate) plan_digest: InitializationPlanDigest,
699 #[serde(skip_serializing)]
700 pub(crate) root_identity: RetainedPhysicalIdentity,
701 #[serde(skip_serializing)]
702 pub(crate) destination_inventory: Vec<InitializationDestinationEntry>,
703}
704
705impl InitializationPlan {
706 pub fn root(&self) -> &std::path::Path {
707 &self.root
708 }
709
710 pub fn folderbase_id(&self) -> &str {
711 &self.folderbase_id
712 }
713
714 pub fn folderbase_name(&self) -> &str {
715 &self.folderbase_name
716 }
717
718 pub fn folderbase_kind(&self) -> FolderbaseKind {
719 self.folderbase_kind
720 }
721
722 pub fn writes(&self) -> &[PlannedWrite] {
723 &self.writes
724 }
725
726 pub fn directories(&self) -> &[PlannedDirectory] {
727 &self.directories
728 }
729
730 pub fn template_preconditions(&self) -> &[TemplateArtifactPrecondition] {
731 &self.template_preconditions
732 }
733
734 pub fn preserved_paths(&self) -> &[PreservedPath] {
735 &self.preserved_paths
736 }
737
738 pub fn warnings(&self) -> &[String] {
739 &self.warnings
740 }
741
742 pub fn plan_digest(&self) -> &InitializationPlanDigest {
743 &self.plan_digest
744 }
745}
746
747#[derive(Debug, Serialize)]
748pub struct TemplateArtifactPrecondition {
749 pub(crate) path: PathBuf,
750 pub(crate) kind: TemplateArtifactKind,
751 #[serde(skip_serializing)]
752 pub(crate) identity: RetainedPhysicalIdentity,
753}
754
755impl TemplateArtifactPrecondition {
756 pub fn path(&self) -> &std::path::Path {
757 &self.path
758 }
759
760 pub fn kind(&self) -> TemplateArtifactKind {
761 self.kind
762 }
763}
764
765#[derive(Debug, Serialize)]
766pub struct PlannedDirectory {
767 pub(crate) path: PathBuf,
768 pub(crate) purpose: String,
769}
770
771impl PlannedDirectory {
772 pub fn path(&self) -> &std::path::Path {
773 &self.path
774 }
775
776 pub fn purpose(&self) -> &str {
777 &self.purpose
778 }
779}
780
781#[derive(Debug, Serialize)]
782pub struct PlannedWrite {
783 pub(crate) path: PathBuf,
784 pub(crate) purpose: String,
785 pub(crate) content: String,
786}
787
788impl PlannedWrite {
789 pub fn path(&self) -> &std::path::Path {
790 &self.path
791 }
792
793 pub fn purpose(&self) -> &str {
794 &self.purpose
795 }
796}
797
798#[derive(Debug, Serialize)]
799pub struct PreservedPath {
800 pub(crate) path: PathBuf,
801}
802
803impl PreservedPath {
804 pub fn path(&self) -> &std::path::Path {
805 &self.path
806 }
807}
808
809#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
810pub struct InitializationResult {
811 pub root: PathBuf,
812 pub folderbase_id: String,
813 pub created_paths: Vec<PathBuf>,
814 pub preserved_paths: Vec<PathBuf>,
815 pub applied_plan_digest: InitializationPlanDigest,
816}
817
818#[derive(Debug, Clone, Copy, Serialize, Deserialize, PartialEq, Eq)]
819#[serde(rename_all = "snake_case")]
820pub enum ValidationLevel {
821 Shallow,
822 ContentIntegrity,
823}
824
825#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
826pub struct ValidationReport {
827 pub root: PathBuf,
828 pub level: ValidationLevel,
829 pub valid: bool,
830 pub findings: Vec<ValidationFinding>,
831}
832
833#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
834pub struct ValidationFinding {
835 pub code: String,
836 pub severity: ValidationSeverity,
837 pub path: Option<PathBuf>,
838 pub message: String,
839}
840
841#[derive(Debug, Clone, Copy, Serialize, Deserialize, PartialEq, Eq)]
842#[serde(rename_all = "snake_case")]
843pub enum ValidationSeverity {
844 Error,
845 Warning,
846}