miden_assembly/linker/
library.rs1use alloc::{sync::Arc, vec::Vec};
2
3use miden_assembly_syntax::module::ModuleDescriptor;
4use miden_core::Word;
5use miden_mast_package::{ManifestValidationError, MastForest, Package};
6pub use miden_project::Linkage;
7
8#[derive(Clone)]
11pub struct LinkLibrary {
12 pub package: Arc<Package>,
13 pub linkage: Linkage,
15}
16
17impl LinkLibrary {
18 pub fn from_package(package: Arc<Package>) -> Self {
20 Self { package, linkage: Linkage::Dynamic }
21 }
22
23 pub fn with_linkage(mut self, linkage: Linkage) -> Self {
25 self.linkage = linkage;
26 self
27 }
28
29 #[inline(always)]
31 pub fn commitment(&self) -> Word {
32 self.mast().commitment()
33 }
34
35 #[inline(always)]
37 pub fn interface_digest(&self) -> Result<Word, ManifestValidationError> {
38 self.package.interface_digest()
39 }
40
41 #[inline(always)]
42 pub fn mast(&self) -> &Arc<MastForest> {
43 self.package.mast_forest()
44 }
45
46 #[inline]
47 pub fn module_descriptors(&self) -> Result<Vec<ModuleDescriptor>, ManifestValidationError> {
48 self.package.try_module_descriptors()
49 }
50}