use super::context::*;
use std::{collections::*, fmt, io, path::*};
#[cfg(any(feature = "blocking", feature = "async"))]
use super::errors::*;
#[cfg(feature = "async")]
use {
std::{future::*, pin::*},
tokio::io::AsyncRead,
};
pub type UrlRef = Box<dyn URL + Send + Sync>;
pub type UrlQuery = HashMap<String, String>;
pub type ReadRef = Box<dyn io::Read>;
#[cfg(feature = "async")]
pub type AsyncReadRef = Pin<Box<dyn AsyncRead>>;
#[cfg(feature = "async")]
pub type ConformFuture = Pin<Box<dyn Future<Output = Result<UrlRef, UrlError>>>>;
#[cfg(feature = "async")]
pub type OpenFuture = Pin<Box<dyn Future<Output = Result<AsyncReadRef, UrlError>>>>;
pub trait URL
where
Self: fmt::Debug + fmt::Display,
{
fn context(&self) -> &UrlContext;
fn key(&self) -> String {
format!("{}", self)
}
fn query(&self) -> Option<UrlQuery> {
None
}
fn fragment(&self) -> Option<String> {
None
}
fn format(&self) -> Option<String> {
None
}
fn local(&self) -> Option<PathBuf> {
None
}
fn base(&self) -> Option<UrlRef> {
None
}
fn relative(&self, path: &str) -> UrlRef;
#[cfg(feature = "blocking")]
fn conform(&mut self) -> Result<(), UrlError>;
#[cfg(feature = "async")]
fn conform_async(&self) -> Result<ConformFuture, UrlError>;
#[cfg(feature = "blocking")]
fn open(&self) -> Result<ReadRef, UrlError>;
#[cfg(feature = "async")]
fn open_async(&self) -> Result<OpenFuture, UrlError>;
}