(&self, spec: &str)
| 113 | } |
| 114 | |
| 115 | fn resolve_canonical(&self, spec: &str) -> Result<Resolved, String> { |
| 116 | let entry = with_runtime(|rt| { |
| 117 | rt.registry.iter().find(|(s, _)| s == spec).map(|(s, e)| { |
| 118 | let cloned = match e { |
| 119 | ModuleEntry::Code(src) => ModuleEntry::Code(src.clone()), |
| 120 | ModuleEntry::Native(funcs) => ModuleEntry::Native(funcs.clone()), |
| 121 | }; |
| 122 | (s.clone(), cloned) |
| 123 | }) |
| 124 | }).ok_or_else(|| s!("module '", str spec, "' not registered (host did not pre-fetch / register before run())"))?; |
| 125 | match entry.1 { |
| 126 | ModuleEntry::Code(src) => Ok(Resolved::Code { |
| 127 | src, |
| 128 | canonical: spec.to_string(), |
| 129 | }), |
| 130 | ModuleEntry::Native(funcs) => { |
| 131 | let all: Vec<NativeBinding> = funcs.iter().map(|(n, id)| make_native_binding(n.clone(), *id)).collect(); |
| 132 | let (bindings, classes, consts) = partition_bindings(all); |
| 133 | Ok(Resolved::Native { bindings, classes, consts, canonical: spec.to_string() }) |
| 134 | } |
| 135 | } |
| 136 | } |
| 137 | } |
| 138 |
no test coverage detected