protospec_build/
import.rs1use crate::{result::*, ForeignFunctionObj, ForeignTransformObj, ForeignTypeObj};
2
3pub trait ImportResolver {
4 fn normalize_import(&self, import: &str) -> Result<String>;
5
6 fn resolve_import(&self, import: &str) -> Result<Option<String>>;
7
8 fn resolve_ffi_transform(&self, name: &str) -> Result<Option<ForeignTransformObj>>;
9
10 fn resolve_ffi_type(&self, name: &str) -> Result<Option<ForeignTypeObj>>;
11
12 fn resolve_ffi_function(&self, name: &str) -> Result<Option<ForeignFunctionObj>>;
13}
14
15pub struct NullImportResolver;
16
17impl ImportResolver for NullImportResolver {
18 fn normalize_import(&self, import: &str) -> Result<String> {
19 Ok(import.to_string())
20 }
21
22 fn resolve_import(&self, _import: &str) -> Result<Option<String>> {
23 Err(protospec_err!("null import resolver"))
24 }
25
26 fn resolve_ffi_transform(&self, _transform: &str) -> Result<Option<ForeignTransformObj>> {
27 Err(protospec_err!("null import resolver"))
28 }
29
30 fn resolve_ffi_type(&self, _type: &str) -> Result<Option<ForeignTypeObj>> {
31 Err(protospec_err!("null import resolver"))
32 }
33
34 fn resolve_ffi_function(&self, _type: &str) -> Result<Option<ForeignFunctionObj>> {
35 Err(protospec_err!("null import resolver"))
36 }
37}