pub struct Artifact {
pub path: String,
pub document: String,
pub format: ArtifactFormat,
pub schema: Option<String>,
pub source: String,
pub content: String,
}Expand description
One generated file: what it projects, how it is encoded, what contract its content satisfies, where it came from, and the whole file.
Fields§
§path: StringRepository-relative path.
document: StringThe document it projects: registry, cli, openapi, capabilities, … Two
artifacts sharing an id are the same document in two encodings.
format: ArtifactFormatThe encoding.
schema: Option<String>The JSON Schema its content satisfies, by schema id, when it declares one.
source: StringOne line: what it was derived from, as the header says it.
content: StringThe whole file.
Implementations§
Source§impl Artifact
impl Artifact
Sourcepub fn markdown(
path: impl Into<String>,
document: impl Into<String>,
source: impl Into<String>,
version: &str,
body: &str,
) -> Artifact
pub fn markdown( path: impl Into<String>, document: impl Into<String>, source: impl Into<String>, version: &str, body: &str, ) -> Artifact
A Markdown artifact: the banner, then the body. Nothing writes the banner itself.
Sourcepub fn text(
path: impl Into<String>,
document: impl Into<String>,
source: impl Into<String>,
version: &str,
body: &str,
) -> Artifact
pub fn text( path: impl Into<String>, document: impl Into<String>, source: impl Into<String>, version: &str, body: &str, ) -> Artifact
A text artifact another program reads line by line: the banner as # comments,
then the lines.
Sourcepub fn json_extension(
path: impl Into<String>,
document: impl Into<String>,
source: impl Into<String>,
version: &str,
value: Value,
) -> Artifact
pub fn json_extension( path: impl Into<String>, document: impl Into<String>, source: impl Into<String>, version: &str, value: Value, ) -> Artifact
A JSON artifact whose own specification fixes its member names — a JSON Schema,
the OpenAPI document — so its provenance goes in x-majordomus- extensions rather
than in members the specification does not define. Both forms are read back by
violations; neither is more generated than the other.
Sourcepub fn comment_text(
path: impl Into<String>,
document: impl Into<String>,
source: impl Into<String>,
version: &str,
body: &str,
) -> Artifact
pub fn comment_text( path: impl Into<String>, document: impl Into<String>, source: impl Into<String>, version: &str, body: &str, ) -> Artifact
A line-oriented text artifact whose banner takes the comment form its suffix
allows: /* */ for a stylesheet or a script, <!-- --> for an SVG, # otherwise.
A stylesheet cannot open with # and an image cannot open with a shell comment;
violations asks for the same form by the same suffix.
use majordomus_cli::generate::Artifact;
let css = Artifact::comment_text("a/b.css", "doc", "the source", "0.1.0", "body { }\n");
assert!(css.content.starts_with("/* GENERATED FILE"), "{}", css.content);
assert!(css.content.ends_with("body { }\n"));
// the same body under a different suffix opens the way that suffix allows
let svg = Artifact::comment_text("a/b.svg", "doc", "the source", "0.1.0", "<svg/>\n");
assert!(svg.content.starts_with("<!-- GENERATED FILE"), "{}", svg.content);Sourcepub fn verbatim(
path: impl Into<String>,
document: impl Into<String>,
format: ArtifactFormat,
schema: Option<String>,
source: impl Into<String>,
content: String,
) -> Artifact
pub fn verbatim( path: impl Into<String>, document: impl Into<String>, format: ArtifactFormat, schema: Option<String>, source: impl Into<String>, content: String, ) -> Artifact
An artifact whose content is taken as it stands: a projection another module renders whole and stamps itself (the provider bootstraps, the site dataset).
Trait Implementations§
impl Eq for Artifact
impl StructuralPartialEq for Artifact
Auto Trait Implementations§
impl Freeze for Artifact
impl RefUnwindSafe for Artifact
impl Send for Artifact
impl Sync for Artifact
impl Unpin for Artifact
impl UnsafeUnpin for Artifact
impl UnwindSafe for Artifact
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.