xsd_parser/parser/resolver/
noop_resolver.rs

1use std::io::{BufRead, Error, ErrorKind};
2
3use url::Url;
4
5use super::{ResolveRequest, Resolver};
6
7/// Implements a [`Resolver`] that resolves nothing.
8///
9/// This is the default resolver that is used if no other resolver was provided.
10#[must_use]
11#[derive(Default, Debug)]
12pub struct NoOpResolver;
13
14impl NoOpResolver {
15    /// Create a new [`NoOpResolver`] resolver instance.
16    pub fn new() -> Self {
17        Self
18    }
19}
20
21impl Resolver for NoOpResolver {
22    type Buffer = Box<dyn BufRead + 'static>;
23    type Error = Error;
24
25    fn resolve(
26        &mut self,
27        req: &ResolveRequest,
28    ) -> Result<Option<(Url, Self::Buffer)>, Self::Error> {
29        Err(Error::new(
30            ErrorKind::NotFound,
31            format!("Unable to resolve requested location: {req}"),
32        ))
33    }
34}