stellation_core/dev.rs
1//! Stellation development server utilities.
2
3use std::path::PathBuf;
4
5use serde::{Deserialize, Serialize};
6
7/// Development server metadata.
8///
9/// This information is passed from stctl to the server when it is started as a development
10/// server.
11#[derive(Clone, Debug, Serialize, Deserialize)]
12pub struct StctlMetadata {
13 /// The address the dev server should listen to.
14 pub listen_addr: String,
15 /// The directory that contains the development build of frontend artifact.
16 pub frontend_dev_build_dir: PathBuf,
17}
18
19impl StctlMetadata {
20 /// The environment variable used by metadata.
21 pub const ENV_NAME: &str = "STCTL_METADATA";
22
23 /// Parses the metadata from a json string.
24 pub fn from_json(s: &str) -> serde_json::Result<Self> {
25 serde_json::from_str(s)
26 }
27
28 /// Serialises the metadata to a json string.
29 pub fn to_json(&self) -> serde_json::Result<String> {
30 serde_json::to_string(self)
31 }
32}