dioxus_dx_wire_format/
lib.rs1use cargo_metadata::{diagnostic::Diagnostic, CompilerMessage};
2use manganis_core::BundledAsset;
3use serde::{Deserialize, Serialize};
4use std::{borrow::Cow, collections::HashSet, path::PathBuf};
5use subsecond_types::JumpTable;
6
7pub use cargo_metadata;
8
9#[allow(clippy::large_enum_variant)]
24#[non_exhaustive]
25#[derive(Serialize, Deserialize, Clone, Debug)]
26pub enum StructuredOutput {
27 BuildsFinished {
28 client: StructuredBuildArtifacts,
29 server: Option<StructuredBuildArtifacts>,
30 },
31 PrintCargoArgs {
32 args: Vec<String>,
33 env: Vec<(Cow<'static, str>, String)>,
34 },
35 BuildFinished {
36 artifacts: StructuredBuildArtifacts,
37 },
38 BuildUpdate {
39 stage: BuildStage,
40 },
41 Hotpatch {
42 jump_table: JumpTable,
43 artifacts: StructuredBuildArtifacts,
44 },
45 CargoOutput {
46 message: CompilerMessage,
47 },
48 RustcOutput {
49 message: Diagnostic,
50 },
51 BundleOutput {
52 bundles: Vec<PathBuf>,
53 client: StructuredBuildArtifacts,
54 server: Option<StructuredBuildArtifacts>,
55 },
56 HtmlTranslate {
57 html: String,
58 },
59 Success,
60 Error {
61 message: String,
62 },
63}
64
65impl std::fmt::Display for StructuredOutput {
66 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
67 f.write_str(&serde_json::to_string(self).map_err(|_e| std::fmt::Error)?)
68 }
69}
70
71#[derive(Debug, Clone, Default, Serialize, Deserialize)]
72pub struct StructuredBuildArtifacts {
73 pub path: PathBuf,
74 pub exe: PathBuf,
75 pub rustc_args: Vec<String>,
76 pub rustc_envs: Vec<(String, String)>,
77 pub link_args: Vec<String>,
78 pub assets: HashSet<BundledAsset>, }
80
81#[non_exhaustive]
85#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Serialize, Deserialize)]
86pub enum BuildStage {
87 Initializing,
88 Starting {
89 crate_count: usize,
90 patch: bool,
91 },
92 InstallingTooling,
93 Compiling {
94 current: usize,
95 total: usize,
96 krate: String,
97 },
98 RunningBindgen,
99 SplittingBundle,
100 OptimizingWasm,
101 Linking,
102 Hotpatching,
103 ExtractingAssets,
104 CopyingAssets {
105 current: usize,
106 total: usize,
107 path: PathBuf,
108 },
109 Bundling,
110 RunningGradle,
111 CodeSigning,
112 Success,
113 Failed,
114 Aborted,
115 Restarting,
116 CompressingAssets,
117 Prerendering,
118}