use super::super::{context::*, errors::*, url::*, util::*};
use {
relative_path::*,
std::{fmt, sync::*},
};
#[derive(Clone, Debug)]
pub struct ZipUrl {
pub archive_url: Arc<UrlRef>,
pub path: RelativePathBuf,
pub(crate) context: UrlContextRef,
}
impl ZipUrl {
pub fn new(context: &UrlContextRef, archive_url: Arc<UrlRef>, path: RelativePathBuf) -> Self {
Self { archive_url, path, context: context.clone() }
}
pub fn new_with(&self, path: RelativePathBuf) -> Self {
Self::new(&self.context, self.archive_url.clone(), path)
}
pub fn parse(url_representation: &str) -> Result<(String, String), UrlError> {
parse_archive_entry_url_representation(url_representation, "zip")
}
}
impl fmt::Display for ZipUrl {
fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(formatter, "zip:{}!{}", self.archive_url, self.path)
}
}
impl Into<UrlRef> for ZipUrl {
fn into(self) -> UrlRef {
Box::new(self)
}
}