use core::borrow::Borrow;
use core::cmp::Ordering;
use core::fmt;
use core::hash::{Hash, Hasher};
use core::str::FromStr;
use std::path::{Path, PathBuf};
use pi_result::{ClassifyErrorKind, ErrorKind, RawResult};
use url::Url;
#[derive(Debug, pi_result::thiserror::Error)]
#[non_exhaustive]
pub enum RemoteLocatorError {
#[error("remote locator URL is invalid")]
InvalidUrl {
#[source]
source: url::ParseError,
},
#[error("remote locator URL must be hierarchical")]
NonHierarchical,
#[error("file URL is not a remote locator")]
FileScheme,
#[error("remote locator URL must not contain credentials")]
Credentials,
#[error("remote locator URL must not contain a query")]
Query,
#[error("remote locator URL must not contain a fragment")]
Fragment,
}
impl ClassifyErrorKind for RemoteLocatorError {
fn classify_error_kind(&self) -> ErrorKind {
todo!("第三批次实现远端定位符错误分类")
}
}
pub struct RemoteLocator {
url: Url,
}
impl RemoteLocator {
pub fn new(url: Url) -> RawResult<Self, RemoteLocatorError> {
todo!("第三批次实现远端定位符构造接口")
}
#[must_use]
pub fn as_url(&self) -> &Url {
todo!("第三批次实现远端 URL 访问接口")
}
#[must_use]
pub fn as_str(&self) -> &str {
todo!("第三批次实现远端 URL 文本访问接口")
}
#[must_use]
pub fn into_url(self) -> Url {
todo!("第三批次实现远端 URL 所有权提取接口")
}
}
impl Clone for RemoteLocator {
fn clone(&self) -> Self {
todo!("第三批次实现远端定位符 Clone 接口")
}
}
impl fmt::Debug for RemoteLocator {
fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
todo!("第三批次实现远端定位符 Debug 接口")
}
}
impl fmt::Display for RemoteLocator {
fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
todo!("第三批次实现远端定位符 Display 接口")
}
}
impl PartialEq for RemoteLocator {
fn eq(&self, other: &Self) -> bool {
todo!("第三批次实现远端定位符 PartialEq 接口")
}
}
impl Eq for RemoteLocator {}
#[allow(clippy::non_canonical_partial_ord_impl)]
impl PartialOrd for RemoteLocator {
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
todo!("第三批次实现远端定位符 PartialOrd 接口")
}
}
impl Ord for RemoteLocator {
fn cmp(&self, other: &Self) -> Ordering {
todo!("第三批次实现远端定位符 Ord 接口")
}
}
impl Hash for RemoteLocator {
fn hash<H>(&self, state: &mut H)
where
H: Hasher,
{
todo!("第三批次实现远端定位符 Hash 接口")
}
}
impl AsRef<Url> for RemoteLocator {
fn as_ref(&self) -> &Url {
todo!("第三批次实现远端定位符 AsRef 接口")
}
}
impl Borrow<Url> for RemoteLocator {
fn borrow(&self) -> &Url {
todo!("第三批次实现远端定位符 Borrow 接口")
}
}
impl TryFrom<Url> for RemoteLocator {
type Error = RemoteLocatorError;
fn try_from(url: Url) -> Result<Self, Self::Error> {
todo!("第三批次实现远端定位符 TryFrom<Url> 接口")
}
}
impl FromStr for RemoteLocator {
type Err = RemoteLocatorError;
fn from_str(text: &str) -> Result<Self, Self::Err> {
todo!("第三批次实现远端定位符 FromStr 接口")
}
}
impl From<RemoteLocator> for Url {
fn from(locator: RemoteLocator) -> Self {
todo!("第三批次实现远端定位符所有权转换")
}
}
#[non_exhaustive]
pub enum FileLocator {
NativePath(PathBuf),
Remote(RemoteLocator),
}
impl Clone for FileLocator {
fn clone(&self) -> Self {
todo!("第三批次实现组合定位符 Clone 接口")
}
}
impl fmt::Debug for FileLocator {
fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
todo!("第三批次实现组合定位符 Debug 接口")
}
}
impl fmt::Display for FileLocator {
fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
todo!("第三批次实现组合定位符 Display 接口")
}
}
impl PartialEq for FileLocator {
fn eq(&self, other: &Self) -> bool {
todo!("第三批次实现组合定位符 PartialEq 接口")
}
}
impl Eq for FileLocator {}
#[allow(clippy::non_canonical_partial_ord_impl)]
impl PartialOrd for FileLocator {
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
todo!("第三批次实现组合定位符 PartialOrd 接口")
}
}
impl Ord for FileLocator {
fn cmp(&self, other: &Self) -> Ordering {
todo!("第三批次实现组合定位符 Ord 接口")
}
}
impl Hash for FileLocator {
fn hash<H>(&self, state: &mut H)
where
H: Hasher,
{
todo!("第三批次实现组合定位符 Hash 接口")
}
}
impl From<PathBuf> for FileLocator {
fn from(path: PathBuf) -> Self {
todo!("第三批次实现组合定位符 From<PathBuf> 接口")
}
}
impl From<&Path> for FileLocator {
fn from(path: &Path) -> Self {
todo!("第三批次实现组合定位符 From<&Path> 接口")
}
}
impl From<RemoteLocator> for FileLocator {
fn from(locator: RemoteLocator) -> Self {
todo!("第三批次实现组合定位符 From<RemoteLocator> 接口")
}
}
impl TryFrom<Url> for FileLocator {
type Error = RemoteLocatorError;
fn try_from(url: Url) -> Result<Self, Self::Error> {
todo!("第三批次实现组合定位符 TryFrom<Url> 接口")
}
}