mirror of
https://github.com/sxyazi/yazi.git
synced 2026-07-25 08:41:05 +00:00
rerstore firmatting diffs
This commit is contained in:
parent
518612857b
commit
83b46c8230
6 changed files with 69 additions and 147 deletions
|
|
@ -1 +1 @@
|
||||||
{"version":"0.2","flagWords":[],"words":["Punct","KEYMAP","splitn","crossterm","YAZI","peekable","ratatui","syntect","pbpaste","pbcopy","oneshot","Posix","Lsar","XADDOS","zoxide","cands","Deque","precache","imageops","IFBLK","IFCHR","IFDIR","IFIFO","IFLNK","IFMT","IFSOCK","IRGRP","IROTH","IRUSR","ISGID","ISUID","ISVTX","IWGRP","IWOTH","IWUSR","IXGRP","IXOTH","IXUSR","libc","winsize","TIOCGWINSZ","xpixel","ypixel","ioerr","appender","Catppuccin","macchiato","gitmodules","Dotfiles","bashprofile","vimrc","flac","webp","exiftool","mediainfo","ripgrep","indexmap","indexmap","unwatch","canonicalize","serde","fsevent","Ueberzug","iterm","wezterm","sixel","chafa","ueberzugpp","Konsole","Überzug","pkgs","pdftoppm","poppler","singlefile","jpegopt","EXIF","rustfmt","mktemp","nanos","xclip","xsel","natord","Mintty","nixos","nixpkgs","SIGTSTP","SIGCONT","SIGCONT","mlua","nonstatic","userdata","metatable","natsort","backstack","luajit","Succ","Succ","cand","fileencoding","foldmethod","lightgreen","darkgray","lightred","lightyellow","lightcyan","nushell","msvc","aarch","linemode","sxyazi","rsplit","ZELLIJ","bitflags","bitflags","USERPROFILE","Neovim","vergen","gitcl","Renderable","preloaders","prec","Upserting","prio","Ghostty","Catmull","Lanczos","cmds","unyank","scrolloff","headsup","unsub","uzers","scopeguard","SPDLOG","globset","filetime","magick","magick","prefetcher","Prework","prefetchers","PREWORKERS","conds","translit","rxvt","Urxvt","realpath","realname","REPARSE","hardlink","hardlinking","nlink","nlink","linemodes","SIGSTOP","sevenzip","rsplitn","replacen","DECSET","DECRQM","repeek","cwds","tcsi","Hyprland","Wayfire","SWAYSOCK","btime","nsec","codegen","gethostname","fchmod","fdfind","Rustc","rustc","ffprobe","vframes","luma","obase","outln","errln","tmtheme","twox","cfgs","fstype","objc","rdev","runloop","exfat","rclone","DECRQSS","DECSCUSR","libvterm","Uninit","lockin","rposition","resvg","foldhash","tilded"],"language":"en"}
|
{"version":"0.2","flagWords":[],"words":["Punct","KEYMAP","splitn","crossterm","YAZI","peekable","ratatui","syntect","pbpaste","pbcopy","oneshot","Posix","Lsar","XADDOS","zoxide","cands","Deque","precache","imageops","IFBLK","IFCHR","IFDIR","IFIFO","IFLNK","IFMT","IFSOCK","IRGRP","IROTH","IRUSR","ISGID","ISUID","ISVTX","IWGRP","IWOTH","IWUSR","IXGRP","IXOTH","IXUSR","libc","winsize","TIOCGWINSZ","xpixel","ypixel","ioerr","appender","Catppuccin","macchiato","gitmodules","Dotfiles","bashprofile","vimrc","flac","webp","exiftool","mediainfo","ripgrep","indexmap","indexmap","unwatch","canonicalize","serde","fsevent","Ueberzug","iterm","wezterm","sixel","chafa","ueberzugpp","Konsole","Überzug","pkgs","pdftoppm","poppler","singlefile","jpegopt","EXIF","rustfmt","mktemp","nanos","xclip","xsel","natord","Mintty","nixos","nixpkgs","SIGTSTP","SIGCONT","SIGCONT","mlua","nonstatic","userdata","metatable","natsort","backstack","luajit","Succ","Succ","cand","fileencoding","foldmethod","lightgreen","darkgray","lightred","lightyellow","lightcyan","nushell","msvc","aarch","linemode","sxyazi","rsplit","ZELLIJ","bitflags","bitflags","USERPROFILE","Neovim","vergen","gitcl","Renderable","preloaders","prec","Upserting","prio","Ghostty","Catmull","Lanczos","cmds","unyank","scrolloff","headsup","unsub","uzers","scopeguard","SPDLOG","globset","filetime","magick","magick","prefetcher","Prework","prefetchers","PREWORKERS","conds","translit","rxvt","Urxvt","realpath","realname","REPARSE","hardlink","hardlinking","nlink","nlink","linemodes","SIGSTOP","sevenzip","rsplitn","replacen","DECSET","DECRQM","repeek","cwds","tcsi","Hyprland","Wayfire","SWAYSOCK","btime","nsec","codegen","gethostname","fchmod","fdfind","Rustc","rustc","ffprobe","vframes","luma","obase","outln","errln","tmtheme","twox","cfgs","fstype","objc","rdev","runloop","exfat","rclone","DECRQSS","DECSCUSR","libvterm","Uninit","lockin","rposition","resvg","foldhash","tilded"],"language":"en"}
|
||||||
|
|
@ -6,10 +6,7 @@ use tokio_stream::{StreamExt, wrappers::UnboundedReceiverStream};
|
||||||
use yazi_config::popup::InputCfg;
|
use yazi_config::popup::InputCfg;
|
||||||
use yazi_fs::{FilesOp, cha::Cha};
|
use yazi_fs::{FilesOp, cha::Cha};
|
||||||
use yazi_macro::{act, succ};
|
use yazi_macro::{act, succ};
|
||||||
use yazi_parser::{
|
use yazi_parser::{VoidOpt, mgr::{SearchOpt, SearchOptVia}};
|
||||||
VoidOpt,
|
|
||||||
mgr::{SearchOpt, SearchOptVia},
|
|
||||||
};
|
|
||||||
use yazi_plugin::external;
|
use yazi_plugin::external;
|
||||||
use yazi_proxy::{InputProxy, MgrProxy};
|
use yazi_proxy::{InputProxy, MgrProxy};
|
||||||
use yazi_shared::event::Data;
|
use yazi_shared::event::Data;
|
||||||
|
|
@ -123,4 +120,4 @@ impl Actor for SearchStop {
|
||||||
}
|
}
|
||||||
succ!();
|
succ!();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1,7 +1,4 @@
|
||||||
use std::{
|
use std::{fs::{FileType, Metadata}, time::SystemTime};
|
||||||
fs::{FileType, Metadata},
|
|
||||||
time::SystemTime,
|
|
||||||
};
|
|
||||||
|
|
||||||
use yazi_macro::{unix_either, win_either};
|
use yazi_macro::{unix_either, win_either};
|
||||||
use yazi_shared::url::Url;
|
use yazi_shared::url::Url;
|
||||||
|
|
@ -11,21 +8,21 @@ use crate::services;
|
||||||
|
|
||||||
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
||||||
pub struct Cha {
|
pub struct Cha {
|
||||||
pub kind: ChaKind,
|
pub kind: ChaKind,
|
||||||
pub len: u64,
|
pub len: u64,
|
||||||
pub atime: Option<SystemTime>,
|
pub atime: Option<SystemTime>,
|
||||||
pub btime: Option<SystemTime>,
|
pub btime: Option<SystemTime>,
|
||||||
#[cfg(unix)]
|
#[cfg(unix)]
|
||||||
pub ctime: Option<SystemTime>,
|
pub ctime: Option<SystemTime>,
|
||||||
pub mtime: Option<SystemTime>,
|
pub mtime: Option<SystemTime>,
|
||||||
#[cfg(unix)]
|
#[cfg(unix)]
|
||||||
pub mode: libc::mode_t,
|
pub mode: libc::mode_t,
|
||||||
#[cfg(unix)]
|
#[cfg(unix)]
|
||||||
pub dev: libc::dev_t,
|
pub dev: libc::dev_t,
|
||||||
#[cfg(unix)]
|
#[cfg(unix)]
|
||||||
pub uid: libc::uid_t,
|
pub uid: libc::uid_t,
|
||||||
#[cfg(unix)]
|
#[cfg(unix)]
|
||||||
pub gid: libc::gid_t,
|
pub gid: libc::gid_t,
|
||||||
#[cfg(unix)]
|
#[cfg(unix)]
|
||||||
pub nlink: libc::nlink_t,
|
pub nlink: libc::nlink_t,
|
||||||
}
|
}
|
||||||
|
|
@ -33,23 +30,23 @@ pub struct Cha {
|
||||||
impl Default for Cha {
|
impl Default for Cha {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
Self {
|
Self {
|
||||||
kind: ChaKind::DUMMY,
|
kind: ChaKind::DUMMY,
|
||||||
len: 0,
|
len: 0,
|
||||||
atime: None,
|
atime: None,
|
||||||
btime: None,
|
btime: None,
|
||||||
#[cfg(unix)]
|
#[cfg(unix)]
|
||||||
ctime: None,
|
ctime: None,
|
||||||
mtime: None,
|
mtime: None,
|
||||||
#[cfg(unix)]
|
#[cfg(unix)]
|
||||||
mode: 0,
|
mode: 0,
|
||||||
#[cfg(unix)]
|
#[cfg(unix)]
|
||||||
dev: 0,
|
dev: 0,
|
||||||
#[cfg(unix)]
|
#[cfg(unix)]
|
||||||
uid: 0,
|
uid: 0,
|
||||||
#[cfg(unix)]
|
#[cfg(unix)]
|
||||||
gid: 0,
|
gid: 0,
|
||||||
#[cfg(unix)]
|
#[cfg(unix)]
|
||||||
nlink: 0,
|
nlink: 0,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -132,10 +129,7 @@ impl Cha {
|
||||||
|
|
||||||
fn from_just_meta(m: &Metadata) -> Self {
|
fn from_just_meta(m: &Metadata) -> Self {
|
||||||
#[cfg(unix)]
|
#[cfg(unix)]
|
||||||
use std::{
|
use std::{os::unix::{fs::MetadataExt, prelude::PermissionsExt}, time::{Duration, UNIX_EPOCH}};
|
||||||
os::unix::{fs::MetadataExt, prelude::PermissionsExt},
|
|
||||||
time::{Duration, UNIX_EPOCH},
|
|
||||||
};
|
|
||||||
|
|
||||||
let mut kind = ChaKind::empty();
|
let mut kind = ChaKind::empty();
|
||||||
if m.is_dir() {
|
if m.is_dir() {
|
||||||
|
|
@ -184,9 +178,7 @@ impl Cha {
|
||||||
|
|
||||||
impl Cha {
|
impl Cha {
|
||||||
#[inline]
|
#[inline]
|
||||||
pub const fn is_dir(&self) -> bool {
|
pub const fn is_dir(&self) -> bool { self.kind.contains(ChaKind::DIR) }
|
||||||
self.kind.contains(ChaKind::DIR)
|
|
||||||
}
|
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub const fn is_hidden(&self) -> bool {
|
pub const fn is_hidden(&self) -> bool {
|
||||||
|
|
@ -197,19 +189,13 @@ impl Cha {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub const fn is_link(&self) -> bool {
|
pub const fn is_link(&self) -> bool { self.kind.contains(ChaKind::LINK) }
|
||||||
self.kind.contains(ChaKind::LINK)
|
|
||||||
}
|
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub const fn is_orphan(&self) -> bool {
|
pub const fn is_orphan(&self) -> bool { self.kind.contains(ChaKind::ORPHAN) }
|
||||||
self.kind.contains(ChaKind::ORPHAN)
|
|
||||||
}
|
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub const fn is_dummy(&self) -> bool {
|
pub const fn is_dummy(&self) -> bool { self.kind.contains(ChaKind::DUMMY) }
|
||||||
self.kind.contains(ChaKind::DUMMY)
|
|
||||||
}
|
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub const fn is_block(&self) -> bool {
|
pub const fn is_block(&self) -> bool {
|
||||||
|
|
@ -232,12 +218,8 @@ impl Cha {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub const fn is_exec(&self) -> bool {
|
pub const fn is_exec(&self) -> bool { unix_either!(self.mode & libc::S_IXUSR != 0, false) }
|
||||||
unix_either!(self.mode & libc::S_IXUSR != 0, false)
|
|
||||||
}
|
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub const fn is_sticky(&self) -> bool {
|
pub const fn is_sticky(&self) -> bool { unix_either!(self.mode & libc::S_ISVTX != 0, false) }
|
||||||
unix_either!(self.mode & libc::S_ISVTX != 0, false)
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -4,9 +4,9 @@ use yazi_shared::{SStr, event::CmdCow};
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct SearchOpt {
|
pub struct SearchOpt {
|
||||||
pub via: SearchOptVia,
|
pub via: SearchOptVia,
|
||||||
pub subject: SStr,
|
pub subject: SStr,
|
||||||
pub args: Vec<String>,
|
pub args: Vec<String>,
|
||||||
pub args_raw: SStr,
|
pub args_raw: SStr,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -36,9 +36,7 @@ impl TryFrom<CmdCow> for SearchOpt {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl IntoLua for &SearchOpt {
|
impl IntoLua for &SearchOpt {
|
||||||
fn into_lua(self, _: &Lua) -> mlua::Result<Value> {
|
fn into_lua(self, _: &Lua) -> mlua::Result<Value> { Err("unsupported".into_lua_err()) }
|
||||||
Err("unsupported".into_lua_err())
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Via
|
// Via
|
||||||
|
|
@ -70,4 +68,4 @@ impl SearchOptVia {
|
||||||
Self::Es => "es",
|
Self::Es => "es",
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
6
yazi-plugin/src/external/es.rs
vendored
6
yazi-plugin/src/external/es.rs
vendored
|
|
@ -2,11 +2,7 @@ use std::path::Path;
|
||||||
use std::process::Stdio;
|
use std::process::Stdio;
|
||||||
|
|
||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
use tokio::{
|
use tokio::{io::{AsyncBufReadExt, BufReader},process::{Child, Command},sync::mpsc::{self, UnboundedReceiver},};
|
||||||
io::{AsyncBufReadExt, BufReader},
|
|
||||||
process::{Child, Command},
|
|
||||||
sync::mpsc::{self, UnboundedReceiver},
|
|
||||||
};
|
|
||||||
use yazi_fs::File;
|
use yazi_fs::File;
|
||||||
use yazi_shared::url::Url;
|
use yazi_shared::url::Url;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,57 +1,37 @@
|
||||||
use std::{
|
use std::{borrow::Cow, ffi::OsStr, fmt::{Debug, Formatter}, hash::BuildHasher, ops::Deref, path::{Path, PathBuf}};
|
||||||
borrow::Cow,
|
|
||||||
ffi::OsStr,
|
|
||||||
fmt::{Debug, Formatter},
|
|
||||||
hash::BuildHasher,
|
|
||||||
ops::Deref,
|
|
||||||
path::{Path, PathBuf},
|
|
||||||
};
|
|
||||||
|
|
||||||
use percent_encoding::percent_decode;
|
use percent_encoding::percent_decode;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
use super::UrnBuf;
|
use super::UrnBuf;
|
||||||
use crate::{
|
use crate::{IntoOsStr, url::{Components, Display, Loc, Scheme}};
|
||||||
IntoOsStr,
|
|
||||||
url::{Components, Display, Loc, Scheme},
|
|
||||||
};
|
|
||||||
|
|
||||||
#[derive(Clone, Default, Eq, Ord, PartialOrd, PartialEq, Hash)]
|
#[derive(Clone, Default, Eq, Ord, PartialOrd, PartialEq, Hash)]
|
||||||
pub struct Url {
|
pub struct Url {
|
||||||
pub loc: Loc,
|
pub loc: Loc,
|
||||||
pub scheme: Scheme,
|
pub scheme: Scheme,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Deref for Url {
|
impl Deref for Url {
|
||||||
type Target = Loc;
|
type Target = Loc;
|
||||||
|
|
||||||
fn deref(&self) -> &Self::Target {
|
fn deref(&self) -> &Self::Target { &self.loc }
|
||||||
&self.loc
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<Loc> for Url {
|
impl From<Loc> for Url {
|
||||||
fn from(loc: Loc) -> Self {
|
fn from(loc: Loc) -> Self { Self { loc, scheme: Scheme::Regular } }
|
||||||
Self { loc, scheme: Scheme::Regular }
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<PathBuf> for Url {
|
impl From<PathBuf> for Url {
|
||||||
fn from(path: PathBuf) -> Self {
|
fn from(path: PathBuf) -> Self { Loc::from(path).into() }
|
||||||
Loc::from(path).into()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<&PathBuf> for Url {
|
impl From<&PathBuf> for Url {
|
||||||
fn from(path: &PathBuf) -> Self {
|
fn from(path: &PathBuf) -> Self { path.to_owned().into() }
|
||||||
path.to_owned().into()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<&Path> for Url {
|
impl From<&Path> for Url {
|
||||||
fn from(path: &Path) -> Self {
|
fn from(path: &Path) -> Self { path.to_path_buf().into() }
|
||||||
path.to_path_buf().into()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl TryFrom<&[u8]> for Url {
|
impl TryFrom<&[u8]> for Url {
|
||||||
|
|
@ -73,48 +53,34 @@ impl TryFrom<&[u8]> for Url {
|
||||||
impl TryFrom<&str> for Url {
|
impl TryFrom<&str> for Url {
|
||||||
type Error = anyhow::Error;
|
type Error = anyhow::Error;
|
||||||
|
|
||||||
fn try_from(value: &str) -> Result<Self, Self::Error> {
|
fn try_from(value: &str) -> Result<Self, Self::Error> { value.as_bytes().try_into() }
|
||||||
value.as_bytes().try_into()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl TryFrom<String> for Url {
|
impl TryFrom<String> for Url {
|
||||||
type Error = anyhow::Error;
|
type Error = anyhow::Error;
|
||||||
|
|
||||||
fn try_from(value: String) -> Result<Self, Self::Error> {
|
fn try_from(value: String) -> Result<Self, Self::Error> { value.as_bytes().try_into() }
|
||||||
value.as_bytes().try_into()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl AsRef<Url> for Url {
|
impl AsRef<Url> for Url {
|
||||||
fn as_ref(&self) -> &Url {
|
fn as_ref(&self) -> &Url { self }
|
||||||
self
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// FIXME: remove
|
// FIXME: remove
|
||||||
impl AsRef<Path> for Url {
|
impl AsRef<Path> for Url {
|
||||||
fn as_ref(&self) -> &Path {
|
fn as_ref(&self) -> &Path { &self.loc }
|
||||||
&self.loc
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> From<&'a Url> for Cow<'a, Url> {
|
impl<'a> From<&'a Url> for Cow<'a, Url> {
|
||||||
fn from(url: &'a Url) -> Self {
|
fn from(url: &'a Url) -> Self { Cow::Borrowed(url) }
|
||||||
Cow::Borrowed(url)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<Url> for Cow<'_, Url> {
|
impl From<Url> for Cow<'_, Url> {
|
||||||
fn from(url: Url) -> Self {
|
fn from(url: Url) -> Self { Cow::Owned(url) }
|
||||||
Cow::Owned(url)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<Cow<'_, Url>> for Url {
|
impl From<Cow<'_, Url>> for Url {
|
||||||
fn from(url: Cow<'_, Url>) -> Self {
|
fn from(url: Cow<'_, Url>) -> Self { url.into_owned() }
|
||||||
url.into_owned()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Url {
|
impl Url {
|
||||||
|
|
@ -139,16 +105,16 @@ impl Url {
|
||||||
Scheme::SearchItem => {
|
Scheme::SearchItem => {
|
||||||
Self { loc: Loc::with(self.loc.base(), self.loc.join(path)), scheme: Scheme::SearchItem }
|
Self { loc: Loc::with(self.loc.base(), self.loc.join(path)), scheme: Scheme::SearchItem }
|
||||||
}
|
}
|
||||||
Scheme::Archive(_) => Self { loc: self.loc.join(path).into(), scheme: self.scheme.clone() },
|
Scheme::Archive(_) => {
|
||||||
|
Self { loc: self.loc.join(path).into(), scheme: self.scheme.clone() }
|
||||||
|
}
|
||||||
Scheme::Sftp(_) => Self { loc: self.loc.join(path).into(), scheme: self.scheme.clone() },
|
Scheme::Sftp(_) => Self { loc: self.loc.join(path).into(), scheme: self.scheme.clone() },
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// FIXME: check usages
|
// FIXME: check usages
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn components(&self) -> Components<'_> {
|
pub fn components(&self) -> Components<'_> { Components::new(self) }
|
||||||
Components::new(self)
|
|
||||||
}
|
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn covariant(&self, other: &Self) -> bool {
|
pub fn covariant(&self, other: &Self) -> bool {
|
||||||
|
|
@ -156,14 +122,10 @@ impl Url {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn display(&self) -> Display<'_> {
|
pub fn display(&self) -> Display<'_> { Display::new(self) }
|
||||||
Display::new(self)
|
|
||||||
}
|
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn os_str(&self) -> Cow<'_, OsStr> {
|
pub fn os_str(&self) -> Cow<'_, OsStr> { self.components().os_str() }
|
||||||
self.components().os_str()
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn parent_url(&self) -> Option<Url> {
|
pub fn parent_url(&self) -> Option<Url> {
|
||||||
let parent = self.loc.parent()?;
|
let parent = self.loc.parent()?;
|
||||||
|
|
@ -189,7 +151,10 @@ impl Url {
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
|
|
||||||
Some(Self { loc: self.loc.strip_prefix(&base.loc).ok()?.into(), scheme: self.scheme.clone() })
|
Some(Self {
|
||||||
|
loc: self.loc.strip_prefix(&base.loc).ok()?.into(),
|
||||||
|
scheme: self.scheme.clone(),
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
|
|
@ -198,19 +163,13 @@ impl Url {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn set_name(&mut self, name: impl AsRef<OsStr>) {
|
pub fn set_name(&mut self, name: impl AsRef<OsStr>) { self.loc.set_name(name); }
|
||||||
self.loc.set_name(name);
|
|
||||||
}
|
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn pair(&self) -> Option<(Self, UrnBuf)> {
|
pub fn pair(&self) -> Option<(Self, UrnBuf)> { Some((self.parent_url()?, self.loc.urn_owned())) }
|
||||||
Some((self.parent_url()?, self.loc.urn_owned()))
|
|
||||||
}
|
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn hash_u64(&self) -> u64 {
|
pub fn hash_u64(&self) -> u64 { foldhash::fast::FixedState::default().hash_one(self) }
|
||||||
foldhash::fast::FixedState::default().hash_one(self)
|
|
||||||
}
|
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn rebase(&self, parent: &Path) -> Self {
|
pub fn rebase(&self, parent: &Path) -> Self {
|
||||||
|
|
@ -222,14 +181,10 @@ impl Url {
|
||||||
impl Url {
|
impl Url {
|
||||||
// --- Regular
|
// --- Regular
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn is_regular(&self) -> bool {
|
pub fn is_regular(&self) -> bool { self.scheme == Scheme::Regular }
|
||||||
self.scheme == Scheme::Regular
|
|
||||||
}
|
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn to_regular(&self) -> Self {
|
pub fn to_regular(&self) -> Self { Self { loc: self.loc.clone(), scheme: Scheme::Regular } }
|
||||||
Self { loc: self.loc.clone(), scheme: Scheme::Regular }
|
|
||||||
}
|
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn into_regular(mut self) -> Self {
|
pub fn into_regular(mut self) -> Self {
|
||||||
|
|
@ -239,9 +194,7 @@ impl Url {
|
||||||
|
|
||||||
// --- Search
|
// --- Search
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn is_search(&self) -> bool {
|
pub fn is_search(&self) -> bool { matches!(self.scheme, Scheme::Search(_)) }
|
||||||
matches!(self.scheme, Scheme::Search(_))
|
|
||||||
}
|
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn to_search(&self, frag: impl AsRef<str>) -> Self {
|
pub fn to_search(&self, frag: impl AsRef<str>) -> Self {
|
||||||
|
|
@ -256,15 +209,11 @@ impl Url {
|
||||||
|
|
||||||
// --- Archive
|
// --- Archive
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn is_archive(&self) -> bool {
|
pub fn is_archive(&self) -> bool { matches!(self.scheme, Scheme::Archive(_)) }
|
||||||
matches!(self.scheme, Scheme::Archive(_))
|
|
||||||
}
|
|
||||||
|
|
||||||
// FIXME: remove
|
// FIXME: remove
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn into_path(self) -> PathBuf {
|
pub fn into_path(self) -> PathBuf { self.loc.into_path() }
|
||||||
self.loc.into_path()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Debug for Url {
|
impl Debug for Url {
|
||||||
|
|
@ -292,4 +241,4 @@ impl<'de> Deserialize<'de> for Url {
|
||||||
let s = String::deserialize(deserializer)?;
|
let s = String::deserialize(deserializer)?;
|
||||||
Self::try_from(s).map_err(serde::de::Error::custom)
|
Self::try_from(s).map_err(serde::de::Error::custom)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Loading…
Add table
Reference in a new issue