pub struct Router { /* private fields */ }Expand description
Resolves links through an ordered parser list and selects the first backend that supports the resulting resource.
Implementations§
Source§impl Router
impl Router
Sourcepub fn new(
parsers: ParserRegistry,
backends: Vec<Arc<dyn DownloadBackend>>,
) -> Self
pub fn new( parsers: ParserRegistry, backends: Vec<Arc<dyn DownloadBackend>>, ) -> Self
Creates a router from parser and backend lists. Both lists are ordered: the first parser that claims a link and the first backend that supports the resulting resource win.
Sourcepub fn parsers(&self) -> &ParserRegistry
pub fn parsers(&self) -> &ParserRegistry
Returns the parser registry used by Router::resolve.
Sourcepub fn backends(&self) -> &[Arc<dyn DownloadBackend>]
pub fn backends(&self) -> &[Arc<dyn DownloadBackend>]
Returns the backends in priority order.
Sourcepub async fn resolve(
&self,
link: &Link,
options: &ParseOptions,
) -> Result<RoutedResource>
pub async fn resolve( &self, link: &Link, options: &ParseOptions, ) -> Result<RoutedResource>
The first parser that claims a link is authoritative. Falling through to a later parser after a Hub metadata error would silently download an HTML page as if it were a file, so parse errors are propagated.
Sourcepub fn backend_for(
&self,
resource: &Resource,
) -> Result<Arc<dyn DownloadBackend>>
pub fn backend_for( &self, resource: &Resource, ) -> Result<Arc<dyn DownloadBackend>>
Returns the first registered backend that supports resource, or
Error::NoBackend when none does.
Auto Trait Implementations§
impl !RefUnwindSafe for Router
impl !UnwindSafe for Router
impl Forget for Router
impl Freeze for Router
impl Move for Router
impl Send for Router
impl Sync for Router
impl Unpin for Router
impl UnsafeUnpin for Router
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