pub struct Resolver { /* private fields */ }Implementations§
Source§impl Resolver
impl Resolver
pub fn new() -> Self
Sourcepub fn resolve(&self, url: &str) -> Result<Vec<Rc<Module>>, UrlParseError>
pub fn resolve(&self, url: &str) -> Result<Vec<Rc<Module>>, UrlParseError>
Examples found in repository?
examples/resolver.rs (line 131)
115fn main() {
116 let manifests = YAMLS
117 .split("---")
118 .map(serde_yaml_ng::from_str::<'_, ModuleManifest>)
119 .map(Result::unwrap);
120 let resolver = Resolver::try_from_iter(manifests).unwrap();
121
122 let mut stdout = std::io::stdout().lock();
123 let mut lines = std::io::stdin().lines();
124 loop {
125 stdout.write_all(b"query > ").unwrap();
126 stdout.flush().unwrap();
127
128 let Some(Ok(query)) = lines.next() else {
129 break;
130 };
131 let answers = resolver.resolve(&query).unwrap();
132 println!("answers:");
133 for answer in answers {
134 println!(" - {}", answer.name);
135 }
136 }
137}pub fn insert_file_extension( &mut self, module: &str, file_extension: &str, ) -> Result<(), Infallible>
pub fn insert_manifest( &mut self, manifest: &ModuleManifest, ) -> Result<(), UrlParseError>
pub fn insert_protocol( &mut self, module: &str, protocol: &str, ) -> Result<(), Infallible>
pub fn insert_prefix( &mut self, module: &str, prefix: &str, ) -> Result<(), UrlParseError>
pub fn insert_pattern( &mut self, module: &str, pattern: &str, ) -> Result<(), UrlParseError>
pub fn try_from_dir(path: impl AsRef<Path>) -> Result<Self, FromDirError>
Sourcepub fn try_from_iter<I, T>(iter: I) -> Result<Self, UrlParseError>
pub fn try_from_iter<I, T>(iter: I) -> Result<Self, UrlParseError>
Examples found in repository?
examples/resolver.rs (line 120)
115fn main() {
116 let manifests = YAMLS
117 .split("---")
118 .map(serde_yaml_ng::from_str::<'_, ModuleManifest>)
119 .map(Result::unwrap);
120 let resolver = Resolver::try_from_iter(manifests).unwrap();
121
122 let mut stdout = std::io::stdout().lock();
123 let mut lines = std::io::stdin().lines();
124 loop {
125 stdout.write_all(b"query > ").unwrap();
126 stdout.flush().unwrap();
127
128 let Some(Ok(query)) = lines.next() else {
129 break;
130 };
131 let answers = resolver.resolve(&query).unwrap();
132 println!("answers:");
133 for answer in answers {
134 println!(" - {}", answer.name);
135 }
136 }
137}Trait Implementations§
Source§impl TryFrom<&[ModuleManifest]> for Resolver
impl TryFrom<&[ModuleManifest]> for Resolver
Source§type Error = UrlParseError
type Error = UrlParseError
The type returned in the event of a conversion error.
Auto Trait Implementations§
impl Freeze for Resolver
impl RefUnwindSafe for Resolver
impl !Send for Resolver
impl !Sync for Resolver
impl Unpin for Resolver
impl UnwindSafe for Resolver
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
Mutably borrows from an owned value. Read more