miden_mast_package/
artifact.rs1use alloc::sync::Arc;
2
3use miden_assembly_syntax::Library;
4use miden_core::{Program, Word, mast::MastForest};
5#[cfg(feature = "serde")]
6use serde::{Deserialize, Serialize};
7
8#[derive(Debug, Clone, Eq, PartialEq, derive_more::From)]
15#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
16pub enum MastArtifact {
17 Executable(Arc<Program>),
19 Library(Arc<Library>),
21}
22
23impl MastArtifact {
24 pub fn unwrap_program(self) -> Arc<Program> {
26 match self {
27 Self::Executable(prog) => prog,
28 Self::Library(_) => panic!("attempted to unwrap 'mast' library as program"),
29 }
30 }
31
32 pub fn unwrap_library(self) -> Arc<Library> {
34 match self {
35 Self::Executable(_) => panic!("attempted to unwrap 'mast' program as library"),
36 Self::Library(lib) => lib,
37 }
38 }
39
40 pub fn digest(&self) -> Word {
42 match self {
43 Self::Executable(prog) => prog.hash(),
44 Self::Library(lib) => *lib.digest(),
45 }
46 }
47
48 pub fn mast_forest(&self) -> &MastForest {
50 match self {
51 Self::Executable(prog) => prog.mast_forest(),
52 Self::Library(lib) => lib.mast_forest(),
53 }
54 }
55}