repo
stringlengths
6
65
file_url
stringlengths
81
311
file_path
stringlengths
6
227
content
stringlengths
0
32.8k
language
stringclasses
1 value
license
stringclasses
7 values
commit_sha
stringlengths
40
40
retrieved_at
stringdate
2026-01-04 15:31:58
2026-01-04 20:25:31
truncated
bool
2 classes
sxyazi/yazi
https://github.com/sxyazi/yazi/blob/3c39a326abaacb37d9ff15af7668756d60624dfa/yazi-fs/src/hash.rs
yazi-fs/src/hash.rs
use std::hash::{BuildHasher, Hash}; use yazi_shared::url::AsUrl; use yazi_shim::Twox128; use crate::{File, cha::Cha}; pub trait FsHash64 { fn hash_u64(&self) -> u64; } impl FsHash64 for File { fn hash_u64(&self) -> u64 { foldhash::fast::FixedState::default().hash_one(self) } } impl<T: AsUrl> FsHash64 for T { fn...
rust
MIT
3c39a326abaacb37d9ff15af7668756d60624dfa
2026-01-04T15:33:17.426354Z
false
sxyazi/yazi
https://github.com/sxyazi/yazi/blob/3c39a326abaacb37d9ff15af7668756d60624dfa/yazi-fs/src/files.rs
yazi-fs/src/files.rs
use std::{mem, ops::{Deref, DerefMut, Not}}; use hashbrown::{HashMap, HashSet}; use yazi_shared::{Id, path::{PathBufDyn, PathDyn}}; use super::{FilesSorter, Filter}; use crate::{FILES_TICKET, File, SortBy}; #[derive(Default)] pub struct Files { hidden: Vec<File>, items: Vec<File>, ticket: Id, ...
rust
MIT
3c39a326abaacb37d9ff15af7668756d60624dfa
2026-01-04T15:33:17.426354Z
false
sxyazi/yazi
https://github.com/sxyazi/yazi/blob/3c39a326abaacb37d9ff15af7668756d60624dfa/yazi-fs/src/sorter.rs
yazi-fs/src/sorter.rs
use std::cmp::Ordering; use hashbrown::HashMap; use rand::{RngCore, SeedableRng, rngs::SmallRng}; use yazi_shared::{natsort, path::PathBufDyn, translit::Transliterator, url::UrlLike}; use crate::{File, SortBy}; #[derive(Clone, Copy, Debug, Default, PartialEq)] pub struct FilesSorter { pub by: SortBy, pub se...
rust
MIT
3c39a326abaacb37d9ff15af7668756d60624dfa
2026-01-04T15:33:17.426354Z
false
sxyazi/yazi
https://github.com/sxyazi/yazi/blob/3c39a326abaacb37d9ff15af7668756d60624dfa/yazi-fs/src/scheme.rs
yazi-fs/src/scheme.rs
use std::path::PathBuf; use yazi_shared::scheme::{AsScheme, Scheme, SchemeRef}; use crate::Xdg; pub trait FsScheme { fn cache(&self) -> Option<PathBuf>; } impl FsScheme for SchemeRef<'_> { fn cache(&self) -> Option<PathBuf> { match self { Self::Regular { .. } | Self::Search { .. } => None, Self::Archive {...
rust
MIT
3c39a326abaacb37d9ff15af7668756d60624dfa
2026-01-04T15:33:17.426354Z
false
sxyazi/yazi
https://github.com/sxyazi/yazi/blob/3c39a326abaacb37d9ff15af7668756d60624dfa/yazi-fs/src/fns.rs
yazi-fs/src/fns.rs
use tokio::io; use yazi_shared::url::{Component, UrlBuf, UrlLike}; #[inline] pub fn ok_or_not_found<T: Default>(result: io::Result<T>) -> io::Result<T> { match result { Ok(t) => Ok(t), Err(e) if e.kind() == io::ErrorKind::NotFound => Ok(T::default()), Err(_) => result, } } // Find the max common root in a lis...
rust
MIT
3c39a326abaacb37d9ff15af7668756d60624dfa
2026-01-04T15:33:17.426354Z
false
sxyazi/yazi
https://github.com/sxyazi/yazi/blob/3c39a326abaacb37d9ff15af7668756d60624dfa/yazi-fs/src/cwd.rs
yazi-fs/src/cwd.rs
use std::{borrow::Cow, env::{current_dir, set_current_dir}, ops::Deref, path::{Path, PathBuf}, sync::{Arc, atomic::{AtomicBool, Ordering}}}; use arc_swap::ArcSwap; use yazi_shared::{RoCell, url::{AsUrl, Url, UrlBuf, UrlLike}}; use crate::{FsUrl, Xdg}; pub static CWD: RoCell<Cwd> = RoCell::new(); pub struct Cwd(ArcS...
rust
MIT
3c39a326abaacb37d9ff15af7668756d60624dfa
2026-01-04T15:33:17.426354Z
false
sxyazi/yazi
https://github.com/sxyazi/yazi/blob/3c39a326abaacb37d9ff15af7668756d60624dfa/yazi-fs/src/error/serde.rs
yazi-fs/src/error/serde.rs
use std::io; use anyhow::{Result, bail}; use serde::{Deserialize, Deserializer, Serialize, Serializer}; use super::Error; pub(super) fn kind_to_str(kind: io::ErrorKind) -> &'static str { use std::io::ErrorKind as K; match kind { K::NotFound => "NotFound", K::PermissionDenied => "PermissionDenied", K::Connect...
rust
MIT
3c39a326abaacb37d9ff15af7668756d60624dfa
2026-01-04T15:33:17.426354Z
false
sxyazi/yazi
https://github.com/sxyazi/yazi/blob/3c39a326abaacb37d9ff15af7668756d60624dfa/yazi-fs/src/error/error.rs
yazi-fs/src/error/error.rs
use std::{fmt, io, sync::Arc}; use anyhow::Result; use crate::error::{kind_from_str, kind_to_str}; #[derive(Clone, Debug, Eq, PartialEq)] pub enum Error { Kind(io::ErrorKind), Raw(i32), Custom { kind: io::ErrorKind, code: Option<i32>, message: Arc<str> }, } impl From<io::Error> for Error { fn from(err: io::Erro...
rust
MIT
3c39a326abaacb37d9ff15af7668756d60624dfa
2026-01-04T15:33:17.426354Z
false
sxyazi/yazi
https://github.com/sxyazi/yazi/blob/3c39a326abaacb37d9ff15af7668756d60624dfa/yazi-fs/src/error/mod.rs
yazi-fs/src/error/mod.rs
yazi_macro::mod_flat!(error serde);
rust
MIT
3c39a326abaacb37d9ff15af7668756d60624dfa
2026-01-04T15:33:17.426354Z
false
sxyazi/yazi
https://github.com/sxyazi/yazi/blob/3c39a326abaacb37d9ff15af7668756d60624dfa/yazi-fs/src/mounts/partitions.rs
yazi-fs/src/mounts/partitions.rs
use std::ops::Deref; use parking_lot::RwLock; use yazi_shared::RoCell; use super::Partition; use crate::cha::Cha; pub(super) type Locked = RwLock<Partitions>; pub static PARTITIONS: RoCell<Locked> = RoCell::new(); #[derive(Default)] pub struct Partitions { pub(super) inner: Vec<Partition>, #[cfg(target_os ...
rust
MIT
3c39a326abaacb37d9ff15af7668756d60624dfa
2026-01-04T15:33:17.426354Z
false
sxyazi/yazi
https://github.com/sxyazi/yazi/blob/3c39a326abaacb37d9ff15af7668756d60624dfa/yazi-fs/src/mounts/macos.rs
yazi-fs/src/mounts/macos.rs
use std::{ffi::{CStr, CString, OsString, c_void}, mem, os::unix::{ffi::OsStringExt, fs::MetadataExt}}; use anyhow::{Result, bail}; use core_foundation_sys::{array::CFArrayRef, base::{CFRelease, kCFAllocatorDefault}, runloop::{CFRunLoopGetCurrent, CFRunLoopRun, kCFRunLoopDefaultMode}}; use libc::{c_char, mach_port_t}; ...
rust
MIT
3c39a326abaacb37d9ff15af7668756d60624dfa
2026-01-04T15:33:17.426354Z
false
sxyazi/yazi
https://github.com/sxyazi/yazi/blob/3c39a326abaacb37d9ff15af7668756d60624dfa/yazi-fs/src/mounts/linux.rs
yazi-fs/src/mounts/linux.rs
use std::{borrow::Cow, ffi::{OsStr, OsString}, os::{fd::AsFd, unix::{ffi::{OsStrExt, OsStringExt}, fs::MetadataExt}}, time::Duration}; use anyhow::{Context, Result}; use hashbrown::{HashMap, HashSet}; use tokio::{io::{Interest, unix::AsyncFd}, time::sleep}; use tracing::error; use yazi_shared::{natsort, replace_cow, r...
rust
MIT
3c39a326abaacb37d9ff15af7668756d60624dfa
2026-01-04T15:33:17.426354Z
false
sxyazi/yazi
https://github.com/sxyazi/yazi/blob/3c39a326abaacb37d9ff15af7668756d60624dfa/yazi-fs/src/mounts/partition.rs
yazi-fs/src/mounts/partition.rs
use std::{ffi::OsString, path::PathBuf}; #[derive(Debug, Default)] pub struct Partition { pub src: OsString, pub dist: Option<PathBuf>, #[cfg(unix)] pub rdev: Option<u64>, pub label: Option<OsString>, pub fstype: Option<OsString>, pub capacity: u64, pub external: Option<bool>, pub rem...
rust
MIT
3c39a326abaacb37d9ff15af7668756d60624dfa
2026-01-04T15:33:17.426354Z
false
sxyazi/yazi
https://github.com/sxyazi/yazi/blob/3c39a326abaacb37d9ff15af7668756d60624dfa/yazi-fs/src/mounts/mod.rs
yazi-fs/src/mounts/mod.rs
yazi_macro::mod_flat!(partition partitions); #[cfg(target_os = "linux")] yazi_macro::mod_flat!(linux); #[cfg(target_os = "macos")] yazi_macro::mod_flat!(macos); pub(super) fn init() { PARTITIONS.init(<_>::default()); }
rust
MIT
3c39a326abaacb37d9ff15af7668756d60624dfa
2026-01-04T15:33:17.426354Z
false
sxyazi/yazi
https://github.com/sxyazi/yazi/blob/3c39a326abaacb37d9ff15af7668756d60624dfa/yazi-fs/src/cha/type.rs
yazi-fs/src/cha/type.rs
use std::fs::FileType; use crate::cha::ChaMode; #[derive(Clone, Copy, Debug, Eq, PartialEq)] pub enum ChaType { File, Dir, Link, Block, Char, Sock, FIFO, Unknown, } impl From<ChaMode> for ChaType { fn from(value: ChaMode) -> Self { *value } } impl From<FileType> for ChaType { fn from(value: FileType) -> S...
rust
MIT
3c39a326abaacb37d9ff15af7668756d60624dfa
2026-01-04T15:33:17.426354Z
false
sxyazi/yazi
https://github.com/sxyazi/yazi/blob/3c39a326abaacb37d9ff15af7668756d60624dfa/yazi-fs/src/cha/kind.rs
yazi-fs/src/cha/kind.rs
use std::fs::Metadata; use bitflags::bitflags; use yazi_shared::strand::AsStrand; bitflags! { #[derive(Clone, Copy, Debug, Default, PartialEq, Eq)] pub struct ChaKind: u8 { const FOLLOW = 0b0000_0001; const HIDDEN = 0b0000_0010; const SYSTEM = 0b0000_0100; const DUMMY = 0b0000_1000; } } impl ChaKind { #...
rust
MIT
3c39a326abaacb37d9ff15af7668756d60624dfa
2026-01-04T15:33:17.426354Z
false
sxyazi/yazi
https://github.com/sxyazi/yazi/blob/3c39a326abaacb37d9ff15af7668756d60624dfa/yazi-fs/src/cha/mod.rs
yazi-fs/src/cha/mod.rs
yazi_macro::mod_flat!(cha kind mode r#type);
rust
MIT
3c39a326abaacb37d9ff15af7668756d60624dfa
2026-01-04T15:33:17.426354Z
false
sxyazi/yazi
https://github.com/sxyazi/yazi/blob/3c39a326abaacb37d9ff15af7668756d60624dfa/yazi-fs/src/cha/cha.rs
yazi-fs/src/cha/cha.rs
use std::{fs::Metadata, ops::Deref, time::{Duration, SystemTime, UNIX_EPOCH}}; use anyhow::bail; use yazi_macro::{unix_either, win_either}; use yazi_shared::{strand::AsStrand, url::AsUrl}; use super::ChaKind; use crate::cha::{ChaMode, ChaType}; #[derive(Clone, Copy, Debug, PartialEq, Eq)] pub struct Cha { pub kind:...
rust
MIT
3c39a326abaacb37d9ff15af7668756d60624dfa
2026-01-04T15:33:17.426354Z
false
sxyazi/yazi
https://github.com/sxyazi/yazi/blob/3c39a326abaacb37d9ff15af7668756d60624dfa/yazi-fs/src/cha/mode.rs
yazi-fs/src/cha/mode.rs
use std::ops::Deref; use anyhow::{anyhow, bail}; use bitflags::bitflags; use crate::cha::ChaType; bitflags! { #[derive(Clone, Copy, Debug, Default, PartialEq, Eq)] pub struct ChaMode: u16 { // File type const T_MASK = 0b1111_0000_0000_0000; const T_SOCK = 0b1100_0000_0000_0000; const T_LINK = 0b1010_...
rust
MIT
3c39a326abaacb37d9ff15af7668756d60624dfa
2026-01-04T15:33:17.426354Z
false
sxyazi/yazi
https://github.com/sxyazi/yazi/blob/3c39a326abaacb37d9ff15af7668756d60624dfa/yazi-fs/src/provider/attrs.rs
yazi-fs/src/provider/attrs.rs
use std::time::{Duration, SystemTime, UNIX_EPOCH}; use crate::cha::{Cha, ChaMode}; #[derive(Clone, Copy, Debug, Default, Eq, PartialEq)] pub struct Attrs { pub mode: Option<ChaMode>, pub atime: Option<SystemTime>, pub btime: Option<SystemTime>, pub mtime: Option<SystemTime>, } impl From<Cha> for Attrs { fn fro...
rust
MIT
3c39a326abaacb37d9ff15af7668756d60624dfa
2026-01-04T15:33:17.426354Z
false
sxyazi/yazi
https://github.com/sxyazi/yazi/blob/3c39a326abaacb37d9ff15af7668756d60624dfa/yazi-fs/src/provider/mod.rs
yazi-fs/src/provider/mod.rs
yazi_macro::mod_pub!(local); yazi_macro::mod_flat!(attrs capabilities traits);
rust
MIT
3c39a326abaacb37d9ff15af7668756d60624dfa
2026-01-04T15:33:17.426354Z
false
sxyazi/yazi
https://github.com/sxyazi/yazi/blob/3c39a326abaacb37d9ff15af7668756d60624dfa/yazi-fs/src/provider/traits.rs
yazi-fs/src/provider/traits.rs
use std::io; use tokio::{io::{AsyncRead, AsyncSeek, AsyncWrite, AsyncWriteExt}, sync::mpsc}; use yazi_macro::ok_or_not_found; use yazi_shared::{path::{AsPath, PathBufDyn}, strand::{AsStrand, StrandCow}, url::{AsUrl, Url, UrlBuf}}; use crate::{cha::{Cha, ChaType}, provider::{Attrs, Capabilities}}; pub trait Provider:...
rust
MIT
3c39a326abaacb37d9ff15af7668756d60624dfa
2026-01-04T15:33:17.426354Z
false
sxyazi/yazi
https://github.com/sxyazi/yazi/blob/3c39a326abaacb37d9ff15af7668756d60624dfa/yazi-fs/src/provider/capabilities.rs
yazi-fs/src/provider/capabilities.rs
#[derive(Clone, Copy, Debug)] pub struct Capabilities { pub symlink: bool, }
rust
MIT
3c39a326abaacb37d9ff15af7668756d60624dfa
2026-01-04T15:33:17.426354Z
false
sxyazi/yazi
https://github.com/sxyazi/yazi/blob/3c39a326abaacb37d9ff15af7668756d60624dfa/yazi-fs/src/provider/local/casefold.rs
yazi-fs/src/provider/local/casefold.rs
use std::{io, path::{Path, PathBuf}}; pub async fn match_name_case(path: impl AsRef<Path>) -> bool { let path = path.as_ref(); casefold(path).await.is_ok_and(|p| p.file_name() == path.file_name()) } pub(super) async fn casefold(path: impl AsRef<Path>) -> io::Result<PathBuf> { let path = path.as_ref().to_owned(); ...
rust
MIT
3c39a326abaacb37d9ff15af7668756d60624dfa
2026-01-04T15:33:17.426354Z
false
sxyazi/yazi
https://github.com/sxyazi/yazi/blob/3c39a326abaacb37d9ff15af7668756d60624dfa/yazi-fs/src/provider/local/local.rs
yazi-fs/src/provider/local/local.rs
use std::{io, path::Path, sync::Arc}; use tokio::sync::mpsc; use yazi_shared::{path::{AsPath, PathBufDyn}, scheme::SchemeKind, strand::AsStrand, url::{Url, UrlBuf, UrlCow}}; use crate::{cha::Cha, provider::{Attrs, Capabilities, Provider}}; #[derive(Clone)] pub struct Local<'a> { url: Url<'a>, path: &'a Path, } i...
rust
MIT
3c39a326abaacb37d9ff15af7668756d60624dfa
2026-01-04T15:33:17.426354Z
false
sxyazi/yazi
https://github.com/sxyazi/yazi/blob/3c39a326abaacb37d9ff15af7668756d60624dfa/yazi-fs/src/provider/local/absolute.rs
yazi-fs/src/provider/local/absolute.rs
use std::path::PathBuf; use yazi_shared::{loc::LocBuf, pool::InternStr, url::{AsUrl, Url, UrlBuf, UrlCow, UrlLike}}; use crate::CWD; pub fn try_absolute<'a, U>(url: U) -> Option<UrlCow<'a>> where U: Into<UrlCow<'a>>, { try_absolute_impl(url.into()) } fn try_absolute_impl<'a>(url: UrlCow<'a>) -> Option<UrlCow<'a>>...
rust
MIT
3c39a326abaacb37d9ff15af7668756d60624dfa
2026-01-04T15:33:17.426354Z
false
sxyazi/yazi
https://github.com/sxyazi/yazi/blob/3c39a326abaacb37d9ff15af7668756d60624dfa/yazi-fs/src/provider/local/gate.rs
yazi-fs/src/provider/local/gate.rs
use std::io; use yazi_shared::url::AsUrl; use crate::provider::{Attrs, FileBuilder}; #[derive(Default)] pub struct Gate(tokio::fs::OpenOptions); impl FileBuilder for Gate { type File = tokio::fs::File; fn append(&mut self, append: bool) -> &mut Self { self.0.append(append); self } fn attrs(&mut self, _att...
rust
MIT
3c39a326abaacb37d9ff15af7668756d60624dfa
2026-01-04T15:33:17.426354Z
false
sxyazi/yazi
https://github.com/sxyazi/yazi/blob/3c39a326abaacb37d9ff15af7668756d60624dfa/yazi-fs/src/provider/local/dir_entry.rs
yazi-fs/src/provider/local/dir_entry.rs
use std::{io, sync::Arc}; use yazi_shared::{path::PathBufDyn, strand::StrandCow, url::{UrlBuf, UrlLike}}; use crate::{cha::{Cha, ChaType}, provider::FileHolder}; pub enum DirEntry { Regular(tokio::fs::DirEntry), Others { entry: tokio::fs::DirEntry, dir: Arc<UrlBuf> }, } impl FileHolder for DirEntry { async fn fi...
rust
MIT
3c39a326abaacb37d9ff15af7668756d60624dfa
2026-01-04T15:33:17.426354Z
false
sxyazi/yazi
https://github.com/sxyazi/yazi/blob/3c39a326abaacb37d9ff15af7668756d60624dfa/yazi-fs/src/provider/local/mod.rs
yazi-fs/src/provider/local/mod.rs
yazi_macro::mod_flat!(absolute calculator casefold copier dir_entry gate identical local read_dir);
rust
MIT
3c39a326abaacb37d9ff15af7668756d60624dfa
2026-01-04T15:33:17.426354Z
false
sxyazi/yazi
https://github.com/sxyazi/yazi/blob/3c39a326abaacb37d9ff15af7668756d60624dfa/yazi-fs/src/provider/local/copier.rs
yazi-fs/src/provider/local/copier.rs
use std::{io, path::PathBuf}; use tokio::{select, sync::{mpsc, oneshot}}; use crate::provider::Attrs; pub(super) async fn copy_impl(from: PathBuf, to: PathBuf, attrs: Attrs) -> io::Result<u64> { #[cfg(any(target_os = "linux", target_os = "android"))] { use std::os::unix::fs::OpenOptionsExt; tokio::task::spawn...
rust
MIT
3c39a326abaacb37d9ff15af7668756d60624dfa
2026-01-04T15:33:17.426354Z
false
sxyazi/yazi
https://github.com/sxyazi/yazi/blob/3c39a326abaacb37d9ff15af7668756d60624dfa/yazi-fs/src/provider/local/read_dir.rs
yazi-fs/src/provider/local/read_dir.rs
use std::{io, sync::Arc}; use yazi_shared::url::UrlBuf; use crate::provider::DirReader; pub enum ReadDir { Regular(tokio::fs::ReadDir), Others { reader: tokio::fs::ReadDir, dir: Arc<UrlBuf> }, } impl DirReader for ReadDir { type Entry = super::DirEntry; async fn next(&mut self) -> io::Result<Option<Self::Entry...
rust
MIT
3c39a326abaacb37d9ff15af7668756d60624dfa
2026-01-04T15:33:17.426354Z
false
sxyazi/yazi
https://github.com/sxyazi/yazi/blob/3c39a326abaacb37d9ff15af7668756d60624dfa/yazi-fs/src/provider/local/calculator.rs
yazi-fs/src/provider/local/calculator.rs
use std::{collections::VecDeque, future::poll_fn, io, mem, path::{Path, PathBuf}, pin::Pin, task::{Poll, ready}, time::{Duration, Instant}}; use tokio::task::JoinHandle; use yazi_shared::Either; type Task = Either<PathBuf, std::fs::ReadDir>; pub enum SizeCalculator { Idle((VecDeque<Task>, Option<u64>)), Pending(Jo...
rust
MIT
3c39a326abaacb37d9ff15af7668756d60624dfa
2026-01-04T15:33:17.426354Z
false
sxyazi/yazi
https://github.com/sxyazi/yazi/blob/3c39a326abaacb37d9ff15af7668756d60624dfa/yazi-fs/src/provider/local/identical.rs
yazi-fs/src/provider/local/identical.rs
use std::{io, path::{Path, PathBuf}}; #[inline] pub async fn identical<P, Q>(a: P, b: Q) -> io::Result<bool> where P: AsRef<Path>, Q: AsRef<Path>, { let (a, b) = (a.as_ref().to_owned(), b.as_ref().to_owned()); tokio::task::spawn_blocking(move || identical_impl(a, b)).await? } #[cfg(unix)] fn identical_impl(a: Pat...
rust
MIT
3c39a326abaacb37d9ff15af7668756d60624dfa
2026-01-04T15:33:17.426354Z
false
sxyazi/yazi
https://github.com/sxyazi/yazi/blob/3c39a326abaacb37d9ff15af7668756d60624dfa/yazi-fs/src/path/expand.rs
yazi-fs/src/path/expand.rs
use std::borrow::Cow; use yazi_shared::{loc::LocBuf, path::{PathBufDyn, PathCow, PathKind, PathLike}, pool::InternStr, url::{AsUrl, Url, UrlBuf, UrlCow, UrlLike}, wtf8::FromWtf8Vec}; #[inline] pub fn expand_url<'a>(url: impl Into<UrlCow<'a>>) -> UrlCow<'a> { expand_url_impl(url.into()) } fn expand_url_impl(url: UrlC...
rust
MIT
3c39a326abaacb37d9ff15af7668756d60624dfa
2026-01-04T15:33:17.426354Z
false
sxyazi/yazi
https://github.com/sxyazi/yazi/blob/3c39a326abaacb37d9ff15af7668756d60624dfa/yazi-fs/src/path/path.rs
yazi-fs/src/path/path.rs
use yazi_shared::{strand::StrandCow, url::{UrlBuf, UrlLike}}; pub fn skip_url(url: &UrlBuf, n: usize) -> StrandCow<'_> { let mut it = url.components(); for _ in 0..n { if it.next().is_none() { return StrandCow::default(); } } it.strand() }
rust
MIT
3c39a326abaacb37d9ff15af7668756d60624dfa
2026-01-04T15:33:17.426354Z
false
sxyazi/yazi
https://github.com/sxyazi/yazi/blob/3c39a326abaacb37d9ff15af7668756d60624dfa/yazi-fs/src/path/mod.rs
yazi-fs/src/path/mod.rs
yazi_macro::mod_flat!(clean expand path percent relative);
rust
MIT
3c39a326abaacb37d9ff15af7668756d60624dfa
2026-01-04T15:33:17.426354Z
false
sxyazi/yazi
https://github.com/sxyazi/yazi/blob/3c39a326abaacb37d9ff15af7668756d60624dfa/yazi-fs/src/path/percent.rs
yazi-fs/src/path/percent.rs
use std::{borrow::Cow, path::{Path, PathBuf}}; use anyhow::Result; use percent_encoding::{AsciiSet, CONTROLS, percent_decode, percent_encode}; use yazi_shared::path::{PathCow, PathDyn, PathKind}; const SET: &AsciiSet = &CONTROLS.add(b'"').add(b'*').add(b':').add(b'<').add(b'>').add(b'?').add(b'\\').add(b'|'); pub t...
rust
MIT
3c39a326abaacb37d9ff15af7668756d60624dfa
2026-01-04T15:33:17.426354Z
false
sxyazi/yazi
https://github.com/sxyazi/yazi/blob/3c39a326abaacb37d9ff15af7668756d60624dfa/yazi-fs/src/path/relative.rs
yazi-fs/src/path/relative.rs
use anyhow::{Result, bail}; use yazi_shared::path::{PathBufDyn, PathCow, PathDyn, PathLike}; pub fn path_relative_to<'a, 'b, P, Q>(from: P, to: Q) -> Result<PathCow<'b>> where P: Into<PathCow<'a>>, Q: Into<PathCow<'b>>, { path_relative_to_impl(from.into(), to.into()) } fn path_relative_to_impl<'a>(from: PathCow<'_...
rust
MIT
3c39a326abaacb37d9ff15af7668756d60624dfa
2026-01-04T15:33:17.426354Z
false
sxyazi/yazi
https://github.com/sxyazi/yazi/blob/3c39a326abaacb37d9ff15af7668756d60624dfa/yazi-fs/src/path/clean.rs
yazi-fs/src/path/clean.rs
use yazi_shared::{path::{PathBufDyn, PathDyn}, url::{UrlBuf, UrlCow, UrlLike}}; pub fn clean_url<'a>(url: impl Into<UrlCow<'a>>) -> UrlBuf { let cow: UrlCow = url.into(); let (path, uri, urn) = clean_path_impl( cow.loc(), cow.base().components().count() - 1, cow.trail().components().count() - 1, ); let sche...
rust
MIT
3c39a326abaacb37d9ff15af7668756d60624dfa
2026-01-04T15:33:17.426354Z
false
sxyazi/yazi
https://github.com/sxyazi/yazi/blob/3c39a326abaacb37d9ff15af7668756d60624dfa/yazi-shared/src/predictor.rs
yazi-shared/src/predictor.rs
// --- BytePredictor pub trait BytePredictor { fn predicate(&self, byte: u8) -> bool; } // --- Utf8BytePredictor pub trait Utf8BytePredictor { fn predicate(&self, byte: u8) -> bool; } // --- AnyAsciiChar pub struct AnyAsciiChar<'a>(&'a [u8]); impl<'a> AnyAsciiChar<'a> { pub fn new(chars: &'a [u8]) -> Option<Self>...
rust
MIT
3c39a326abaacb37d9ff15af7668756d60624dfa
2026-01-04T15:33:17.426354Z
false
sxyazi/yazi
https://github.com/sxyazi/yazi/blob/3c39a326abaacb37d9ff15af7668756d60624dfa/yazi-shared/src/throttle.rs
yazi-shared/src/throttle.rs
use std::{fmt::Debug, mem, sync::atomic::{AtomicU64, AtomicUsize, Ordering}, time::Duration}; use parking_lot::Mutex; use crate::timestamp_us; #[derive(Debug)] pub struct Throttle<T> { total: AtomicUsize, interval: Duration, last: AtomicU64, buf: Mutex<Vec<T>>, } impl<T> Throttle<T> { pub fn new(to...
rust
MIT
3c39a326abaacb37d9ff15af7668756d60624dfa
2026-01-04T15:33:17.426354Z
false
sxyazi/yazi
https://github.com/sxyazi/yazi/blob/3c39a326abaacb37d9ff15af7668756d60624dfa/yazi-shared/src/bytes.rs
yazi-shared/src/bytes.rs
use std::fmt::Display; use crate::BytePredictor; pub trait BytesExt { fn display(&self) -> impl Display; fn kebab_cased(&self) -> bool; fn rsplit_pred_once<P: BytePredictor>(&self, pred: P) -> Option<(&[u8], &[u8])>; fn rsplit_seq_once(&self, sep: &[u8]) -> Option<(&[u8], &[u8])>; fn split_seq_once(&self, se...
rust
MIT
3c39a326abaacb37d9ff15af7668756d60624dfa
2026-01-04T15:33:17.426354Z
false
sxyazi/yazi
https://github.com/sxyazi/yazi/blob/3c39a326abaacb37d9ff15af7668756d60624dfa/yazi-shared/src/source.rs
yazi-shared/src/source.rs
use serde::{Deserialize, Serialize}; #[derive(Clone, Copy, Debug, Default, Deserialize, Eq, PartialEq, Serialize)] pub enum Source { #[default] Unknown, Key, Emit, Relay, Ind, } impl Source { #[inline] pub fn is_key(self) -> bool { self == Self::Key } #[inline] pub fn is_ind(self) -> bool { self == Self:...
rust
MIT
3c39a326abaacb37d9ff15af7668756d60624dfa
2026-01-04T15:33:17.426354Z
false
sxyazi/yazi
https://github.com/sxyazi/yazi/blob/3c39a326abaacb37d9ff15af7668756d60624dfa/yazi-shared/src/lib.rs
yazi-shared/src/lib.rs
yazi_macro::mod_pub!(data errors event loc path pool scheme shell strand translit url wtf8); yazi_macro::mod_flat!(alias bytes chars completion_token condition debounce either env id layer localset natsort os predictor ro_cell source sync_cell terminal tests throttle time utf8); pub fn init() { LOCAL_SET.with(tokio:...
rust
MIT
3c39a326abaacb37d9ff15af7668756d60624dfa
2026-01-04T15:33:17.426354Z
false
sxyazi/yazi
https://github.com/sxyazi/yazi/blob/3c39a326abaacb37d9ff15af7668756d60624dfa/yazi-shared/src/completion_token.rs
yazi-shared/src/completion_token.rs
use std::sync::{Arc, atomic::{AtomicU8, Ordering}}; use tokio::sync::Notify; #[derive(Clone, Debug, Default)] pub struct CompletionToken { inner: Arc<(AtomicU8, Notify)>, } impl CompletionToken { pub fn complete(&self, success: bool) { let new = if success { 1 } else { 2 }; self.inner.0.compare_exchange(0, new...
rust
MIT
3c39a326abaacb37d9ff15af7668756d60624dfa
2026-01-04T15:33:17.426354Z
false
sxyazi/yazi
https://github.com/sxyazi/yazi/blob/3c39a326abaacb37d9ff15af7668756d60624dfa/yazi-shared/src/tests.rs
yazi-shared/src/tests.rs
pub fn init_tests() { static INIT: std::sync::OnceLock<()> = std::sync::OnceLock::new(); INIT.get_or_init(|| { crate::init(); }); }
rust
MIT
3c39a326abaacb37d9ff15af7668756d60624dfa
2026-01-04T15:33:17.426354Z
false
sxyazi/yazi
https://github.com/sxyazi/yazi/blob/3c39a326abaacb37d9ff15af7668756d60624dfa/yazi-shared/src/id.rs
yazi-shared/src/id.rs
use std::{fmt::Display, str::FromStr, sync::atomic::{AtomicU64, Ordering}}; use serde::{Deserialize, Serialize}; #[derive( Clone, Copy, Debug, Default, Deserialize, Eq, Hash, Ord, PartialEq, PartialOrd, Serialize, )] pub struct Id(pub u64); impl Id { #[inline] pub const fn get(&self) -> u64 { self.0 } pub fn un...
rust
MIT
3c39a326abaacb37d9ff15af7668756d60624dfa
2026-01-04T15:33:17.426354Z
false
sxyazi/yazi
https://github.com/sxyazi/yazi/blob/3c39a326abaacb37d9ff15af7668756d60624dfa/yazi-shared/src/os.rs
yazi-shared/src/os.rs
#[cfg(unix)] pub static USERS_CACHE: crate::RoCell<uzers::UsersCache> = crate::RoCell::new(); #[cfg(unix)] pub fn hostname() -> Option<&'static str> { static CACHE: std::sync::OnceLock<Option<String>> = std::sync::OnceLock::new(); CACHE.get_or_init(|| hostname_impl().ok()).as_deref() } #[cfg(unix)] fn hostname_imp...
rust
MIT
3c39a326abaacb37d9ff15af7668756d60624dfa
2026-01-04T15:33:17.426354Z
false
sxyazi/yazi
https://github.com/sxyazi/yazi/blob/3c39a326abaacb37d9ff15af7668756d60624dfa/yazi-shared/src/natsort.rs
yazi-shared/src/natsort.rs
// A natural sort implementation in Rust. // Copyright (c) 2023, sxyazi. // // This is a port of the C version of Martin Pool's `strnatcmp.c`: // http://sourcefrog.net/projects/natsort/ use std::cmp::Ordering; macro_rules! return_unless_equal { ($ord:expr) => { match $ord { Ordering::Equal => {} ord => retur...
rust
MIT
3c39a326abaacb37d9ff15af7668756d60624dfa
2026-01-04T15:33:17.426354Z
false
sxyazi/yazi
https://github.com/sxyazi/yazi/blob/3c39a326abaacb37d9ff15af7668756d60624dfa/yazi-shared/src/time.rs
yazi-shared/src/time.rs
use std::time::{SystemTime, UNIX_EPOCH}; #[inline] pub fn timestamp_us() -> u64 { SystemTime::now().duration_since(UNIX_EPOCH).expect("Time went backwards").as_micros() as _ }
rust
MIT
3c39a326abaacb37d9ff15af7668756d60624dfa
2026-01-04T15:33:17.426354Z
false
sxyazi/yazi
https://github.com/sxyazi/yazi/blob/3c39a326abaacb37d9ff15af7668756d60624dfa/yazi-shared/src/chars.rs
yazi-shared/src/chars.rs
use core::str; use std::borrow::Cow; #[derive(Clone, Copy, PartialEq, Eq)] pub enum CharKind { Space, Punct, Other, } impl CharKind { pub fn new(c: char) -> Self { if c.is_whitespace() { Self::Space } else if c.is_ascii_punctuation() { Self::Punct } else { Self::Other } } pub fn vary(self, oth...
rust
MIT
3c39a326abaacb37d9ff15af7668756d60624dfa
2026-01-04T15:33:17.426354Z
false
sxyazi/yazi
https://github.com/sxyazi/yazi/blob/3c39a326abaacb37d9ff15af7668756d60624dfa/yazi-shared/src/env.rs
yazi-shared/src/env.rs
use std::fmt::{Display, Formatter}; pub static LOG_LEVEL: crate::SyncCell<LogLevel> = crate::SyncCell::new(LogLevel::None); #[inline] pub fn env_exists(name: &str) -> bool { std::env::var_os(name).is_some_and(|s| !s.is_empty()) } #[inline] pub fn in_wsl() -> bool { #[cfg(target_os = "linux")] { std::fs::symlink_...
rust
MIT
3c39a326abaacb37d9ff15af7668756d60624dfa
2026-01-04T15:33:17.426354Z
false
sxyazi/yazi
https://github.com/sxyazi/yazi/blob/3c39a326abaacb37d9ff15af7668756d60624dfa/yazi-shared/src/layer.rs
yazi-shared/src/layer.rs
use std::{fmt::Display, str::FromStr}; use serde::Deserialize; #[derive(Debug, Default, PartialEq, Eq, Hash, Clone, Copy, Deserialize)] #[serde(rename_all = "kebab-case")] pub enum Layer { #[default] App, Mgr, Tasks, Spot, Pick, Input, Confirm, Help, Cmp, Which, } impl Display for Layer { fn fmt(&self, f...
rust
MIT
3c39a326abaacb37d9ff15af7668756d60624dfa
2026-01-04T15:33:17.426354Z
false
sxyazi/yazi
https://github.com/sxyazi/yazi/blob/3c39a326abaacb37d9ff15af7668756d60624dfa/yazi-shared/src/localset.rs
yazi-shared/src/localset.rs
use tokio::task::LocalSet; use crate::RoCell; pub static LOCAL_SET: RoCell<LocalSet> = RoCell::new();
rust
MIT
3c39a326abaacb37d9ff15af7668756d60624dfa
2026-01-04T15:33:17.426354Z
false
sxyazi/yazi
https://github.com/sxyazi/yazi/blob/3c39a326abaacb37d9ff15af7668756d60624dfa/yazi-shared/src/ro_cell.rs
yazi-shared/src/ro_cell.rs
use std::{cell::UnsafeCell, fmt::{self, Display}, mem::MaybeUninit, ops::Deref}; // Read-only cell. It's safe to use this in a static variable, but it's not safe // to mutate it. This is useful for storing static data that is expensive to // initialize, but is immutable once. pub struct RoCell<T> { inner: Unsaf...
rust
MIT
3c39a326abaacb37d9ff15af7668756d60624dfa
2026-01-04T15:33:17.426354Z
false
sxyazi/yazi
https://github.com/sxyazi/yazi/blob/3c39a326abaacb37d9ff15af7668756d60624dfa/yazi-shared/src/either.rs
yazi-shared/src/either.rs
use serde::Serialize; #[derive(Clone, Copy, Debug)] pub enum Either<L, R> { Left(L), Right(R), } impl<L, R> Either<L, R> { pub fn left(&self) -> Option<&L> { match self { Self::Left(l) => Some(l), _ => None, } } pub fn right(&self) -> Option<&R> { match self { Self::Right(r) => Some(r), _ => N...
rust
MIT
3c39a326abaacb37d9ff15af7668756d60624dfa
2026-01-04T15:33:17.426354Z
false
sxyazi/yazi
https://github.com/sxyazi/yazi/blob/3c39a326abaacb37d9ff15af7668756d60624dfa/yazi-shared/src/debounce.rs
yazi-shared/src/debounce.rs
use std::{pin::Pin, task::{Context, Poll}, time::Duration}; use futures::{FutureExt, Stream, StreamExt}; use tokio::time::{Instant, Sleep, sleep}; pub struct Debounce<S> where S: Stream, { stream: S, interval: Duration, sleep: Sleep, last: Option<S::Item>, } impl<S> Debounce<S> where S: Stream + Unpin, { ...
rust
MIT
3c39a326abaacb37d9ff15af7668756d60624dfa
2026-01-04T15:33:17.426354Z
false
sxyazi/yazi
https://github.com/sxyazi/yazi/blob/3c39a326abaacb37d9ff15af7668756d60624dfa/yazi-shared/src/terminal.rs
yazi-shared/src/terminal.rs
use std::io::Write; use crossterm::execute; #[inline] pub fn terminal_clear(mut w: impl Write) -> std::io::Result<()> { execute!( w, crossterm::terminal::Clear(crossterm::terminal::ClearType::All), crossterm::style::Print("\n") ) }
rust
MIT
3c39a326abaacb37d9ff15af7668756d60624dfa
2026-01-04T15:33:17.426354Z
false
sxyazi/yazi
https://github.com/sxyazi/yazi/blob/3c39a326abaacb37d9ff15af7668756d60624dfa/yazi-shared/src/alias.rs
yazi-shared/src/alias.rs
pub type SStr = std::borrow::Cow<'static, str>;
rust
MIT
3c39a326abaacb37d9ff15af7668756d60624dfa
2026-01-04T15:33:17.426354Z
false
sxyazi/yazi
https://github.com/sxyazi/yazi/blob/3c39a326abaacb37d9ff15af7668756d60624dfa/yazi-shared/src/condition.rs
yazi-shared/src/condition.rs
use std::str::FromStr; use anyhow::bail; use serde::{Deserialize, Deserializer, de}; #[derive(Debug, PartialEq, Eq)] pub enum ConditionOp { Or, And, Not, // Only used in `build()` Space, LeftParen, RightParen, Unknown, // Only used in `eval()` Term(String), } impl ConditionOp { pub fn new(c: char) -> Se...
rust
MIT
3c39a326abaacb37d9ff15af7668756d60624dfa
2026-01-04T15:33:17.426354Z
false
sxyazi/yazi
https://github.com/sxyazi/yazi/blob/3c39a326abaacb37d9ff15af7668756d60624dfa/yazi-shared/src/sync_cell.rs
yazi-shared/src/sync_cell.rs
use std::{cell::Cell, fmt::{Debug, Display, Formatter}, ops::Deref}; use serde::{Deserialize, Deserializer, Serialize, Serializer}; /// [`SyncCell`], but [`Sync`]. /// /// This is just an `Cell`, except it implements `Sync` /// if `T` implements `Sync`. pub struct SyncCell<T: ?Sized>(Cell<T>); unsafe impl<T: ?Sized ...
rust
MIT
3c39a326abaacb37d9ff15af7668756d60624dfa
2026-01-04T15:33:17.426354Z
false
sxyazi/yazi
https://github.com/sxyazi/yazi/blob/3c39a326abaacb37d9ff15af7668756d60624dfa/yazi-shared/src/utf8.rs
yazi-shared/src/utf8.rs
// https://tools.ietf.org/html/rfc3629 const UTF8_CHAR_WIDTH: &[u8; 256] = &[ // 1 2 3 4 5 6 7 8 9 A B C D E F 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 1 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 2 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
rust
MIT
3c39a326abaacb37d9ff15af7668756d60624dfa
2026-01-04T15:33:17.426354Z
false
sxyazi/yazi
https://github.com/sxyazi/yazi/blob/3c39a326abaacb37d9ff15af7668756d60624dfa/yazi-shared/src/wtf8/wtf8.rs
yazi-shared/src/wtf8/wtf8.rs
use std::ffi::{OsStr, OsString}; use anyhow::Result; // --- AsWtf8 pub trait AsWtf8 { fn as_wtf8(&self) -> &[u8]; } impl AsWtf8 for OsStr { fn as_wtf8(&self) -> &[u8] { #[cfg(unix)] { use std::os::unix::ffi::OsStrExt; self.as_bytes() } #[cfg(windows)] { self.as_encoded_bytes() } } } // --- F...
rust
MIT
3c39a326abaacb37d9ff15af7668756d60624dfa
2026-01-04T15:33:17.426354Z
false
sxyazi/yazi
https://github.com/sxyazi/yazi/blob/3c39a326abaacb37d9ff15af7668756d60624dfa/yazi-shared/src/wtf8/mod.rs
yazi-shared/src/wtf8/mod.rs
yazi_macro::mod_flat!(validator wtf8);
rust
MIT
3c39a326abaacb37d9ff15af7668756d60624dfa
2026-01-04T15:33:17.426354Z
false
sxyazi/yazi
https://github.com/sxyazi/yazi/blob/3c39a326abaacb37d9ff15af7668756d60624dfa/yazi-shared/src/wtf8/validator.rs
yazi-shared/src/wtf8/validator.rs
#[cfg(windows)] pub(super) fn valid_wtf8(bytes: &[u8]) -> bool { let mut i = 0; while i < bytes.len() { let b = bytes[i]; if b < 0b1000_0000 { // ASCII i += 1; continue; } // 2-byte: 110x_xxxx 10xx_xxxx // first byte must be >= 0b1100_0010 to forbid overlongs if (b & 0b1110_0000) == 0b1100_0000 ...
rust
MIT
3c39a326abaacb37d9ff15af7668756d60624dfa
2026-01-04T15:33:17.426354Z
false
sxyazi/yazi
https://github.com/sxyazi/yazi/blob/3c39a326abaacb37d9ff15af7668756d60624dfa/yazi-shared/src/pool/mod.rs
yazi-shared/src/pool/mod.rs
yazi_macro::mod_flat!(cow pool ptr symbol traits); static SYMBOLS: crate::RoCell< parking_lot::Mutex<hashbrown::HashMap<SymbolPtr, u64, foldhash::fast::FixedState>>, > = crate::RoCell::new(); pub(super) fn init() { SYMBOLS.with(<_>::default); } #[inline] pub(super) fn compute_hash<T: std::hash::Hash>(value: T) -> u...
rust
MIT
3c39a326abaacb37d9ff15af7668756d60624dfa
2026-01-04T15:33:17.426354Z
false
sxyazi/yazi
https://github.com/sxyazi/yazi/blob/3c39a326abaacb37d9ff15af7668756d60624dfa/yazi-shared/src/pool/cow.rs
yazi-shared/src/pool/cow.rs
use std::ops::Deref; use crate::pool::{Pool, Symbol}; pub enum SymbolCow<'a, T: ?Sized> { Borrowed(&'a T), Owned(Symbol<T>), } impl<T: ?Sized> Clone for SymbolCow<'_, T> { fn clone(&self) -> Self { match self { Self::Borrowed(t) => Self::Borrowed(t), Self::Owned(t) => Self::Owned(t.clone()), } } } imp...
rust
MIT
3c39a326abaacb37d9ff15af7668756d60624dfa
2026-01-04T15:33:17.426354Z
false
sxyazi/yazi
https://github.com/sxyazi/yazi/blob/3c39a326abaacb37d9ff15af7668756d60624dfa/yazi-shared/src/pool/ptr.rs
yazi-shared/src/pool/ptr.rs
use std::{borrow::Borrow, hash::{Hash, Hasher}, ops::Deref, ptr::NonNull}; use hashbrown::Equivalent; #[derive(Debug, Clone, PartialEq, Eq)] pub(super) struct SymbolPtr(NonNull<[u8]>); unsafe impl Send for SymbolPtr {} unsafe impl Sync for SymbolPtr {} impl Deref for SymbolPtr { type Target = NonNull<[u8]>; fn ...
rust
MIT
3c39a326abaacb37d9ff15af7668756d60624dfa
2026-01-04T15:33:17.426354Z
false
sxyazi/yazi
https://github.com/sxyazi/yazi/blob/3c39a326abaacb37d9ff15af7668756d60624dfa/yazi-shared/src/pool/traits.rs
yazi-shared/src/pool/traits.rs
use crate::pool::{Pool, Symbol}; pub trait InternStr { fn intern(&self) -> Symbol<str>; } impl<T: AsRef<str>> InternStr for T { fn intern(&self) -> Symbol<str> { Pool::<str>::intern(self) } }
rust
MIT
3c39a326abaacb37d9ff15af7668756d60624dfa
2026-01-04T15:33:17.426354Z
false
sxyazi/yazi
https://github.com/sxyazi/yazi/blob/3c39a326abaacb37d9ff15af7668756d60624dfa/yazi-shared/src/pool/pool.rs
yazi-shared/src/pool/pool.rs
use std::marker::PhantomData; use hashbrown::hash_map::RawEntryMut; use crate::pool::{SYMBOLS, Symbol, SymbolPtr, compute_hash}; pub struct Pool<T: ?Sized> { _phantom: PhantomData<T>, } impl Pool<[u8]> { pub fn intern(value: &[u8]) -> Symbol<[u8]> { let hash = compute_hash(value); match SYMBOLS.lock().raw_en...
rust
MIT
3c39a326abaacb37d9ff15af7668756d60624dfa
2026-01-04T15:33:17.426354Z
false
sxyazi/yazi
https://github.com/sxyazi/yazi/blob/3c39a326abaacb37d9ff15af7668756d60624dfa/yazi-shared/src/pool/symbol.rs
yazi-shared/src/pool/symbol.rs
use std::{hash::{Hash, Hasher}, marker::PhantomData, mem::ManuallyDrop, ops::Deref, str}; use hashbrown::hash_map::RawEntryMut; use crate::pool::{Pool, SYMBOLS, SymbolPtr, compute_hash}; pub struct Symbol<T: ?Sized> { ptr: SymbolPtr, _phantom: PhantomData<T>, } unsafe impl<T: ?Sized> Send for Symbol<T> {} u...
rust
MIT
3c39a326abaacb37d9ff15af7668756d60624dfa
2026-01-04T15:33:17.426354Z
false
sxyazi/yazi
https://github.com/sxyazi/yazi/blob/3c39a326abaacb37d9ff15af7668756d60624dfa/yazi-shared/src/errors/peek.rs
yazi-shared/src/errors/peek.rs
use std::{error::Error, fmt::{self, Display}}; #[derive(Debug)] pub enum PeekError { Exceed(usize), Unexpected(String), } impl Display for PeekError { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match self { Self::Exceed(lines) => write!(f, "Exceed maximum lines {lines}"), Self::Unexpected(m...
rust
MIT
3c39a326abaacb37d9ff15af7668756d60624dfa
2026-01-04T15:33:17.426354Z
false
sxyazi/yazi
https://github.com/sxyazi/yazi/blob/3c39a326abaacb37d9ff15af7668756d60624dfa/yazi-shared/src/errors/mod.rs
yazi-shared/src/errors/mod.rs
yazi_macro::mod_flat!(input peek);
rust
MIT
3c39a326abaacb37d9ff15af7668756d60624dfa
2026-01-04T15:33:17.426354Z
false
sxyazi/yazi
https://github.com/sxyazi/yazi/blob/3c39a326abaacb37d9ff15af7668756d60624dfa/yazi-shared/src/errors/input.rs
yazi-shared/src/errors/input.rs
use std::{error::Error, fmt::{self, Display}}; use crate::Id; #[derive(Debug)] pub enum InputError { Typed(String), Completed(String, Id), Canceled(String), } impl Display for InputError { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match self { Self::Typed(text) => write!(f, "Typed error: {t...
rust
MIT
3c39a326abaacb37d9ff15af7668756d60624dfa
2026-01-04T15:33:17.426354Z
false
sxyazi/yazi
https://github.com/sxyazi/yazi/blob/3c39a326abaacb37d9ff15af7668756d60624dfa/yazi-shared/src/url/encode.rs
yazi-shared/src/url/encode.rs
use std::fmt::{self, Display}; use percent_encoding::{CONTROLS, percent_encode}; use crate::url::Url; #[derive(Clone, Copy)] pub struct Encode<'a>(pub Url<'a>); impl Display for Encode<'_> { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { use crate::scheme::Encode as E; let loc = percent_encode(sel...
rust
MIT
3c39a326abaacb37d9ff15af7668756d60624dfa
2026-01-04T15:33:17.426354Z
false
sxyazi/yazi
https://github.com/sxyazi/yazi/blob/3c39a326abaacb37d9ff15af7668756d60624dfa/yazi-shared/src/url/cov.rs
yazi-shared/src/url/cov.rs
use std::{hash::{Hash, Hasher}, ops::Deref, path::PathBuf}; use hashbrown::Equivalent; use serde::{Deserialize, Serialize}; use crate::url::{AsUrl, Url, UrlBuf, UrlCow, UrlLike}; #[derive(Clone, Copy)] pub struct UrlCov<'a>(Url<'a>); impl<'a> Deref for UrlCov<'a> { type Target = Url<'a>; fn deref(&self) -> &Self...
rust
MIT
3c39a326abaacb37d9ff15af7668756d60624dfa
2026-01-04T15:33:17.426354Z
false
sxyazi/yazi
https://github.com/sxyazi/yazi/blob/3c39a326abaacb37d9ff15af7668756d60624dfa/yazi-shared/src/url/like.rs
yazi-shared/src/url/like.rs
use std::{borrow::Cow, ffi::OsStr, path::Path}; use anyhow::Result; use crate::{path::{AsPathRef, EndsWithError, JoinError, PathDyn, StartsWithError, StripPrefixError}, scheme::{SchemeKind, SchemeRef}, strand::{AsStrand, Strand}, url::{AsUrl, Components, Display, Url, UrlBuf, UrlCow}}; pub trait UrlLike where Self:...
rust
MIT
3c39a326abaacb37d9ff15af7668756d60624dfa
2026-01-04T15:33:17.426354Z
false
sxyazi/yazi
https://github.com/sxyazi/yazi/blob/3c39a326abaacb37d9ff15af7668756d60624dfa/yazi-shared/src/url/url.rs
yazi-shared/src/url/url.rs
use std::{borrow::Cow, ffi::OsStr, fmt::{Debug, Formatter}, path::{Path, PathBuf}}; use anyhow::Result; use hashbrown::Equivalent; use serde::Serialize; use super::Encode as EncodeUrl; use crate::{loc::{Loc, LocBuf}, path::{AsPath, AsPathRef, EndsWithError, JoinError, PathBufDyn, PathDyn, PathDynError, PathLike, Star...
rust
MIT
3c39a326abaacb37d9ff15af7668756d60624dfa
2026-01-04T15:33:17.426354Z
false
sxyazi/yazi
https://github.com/sxyazi/yazi/blob/3c39a326abaacb37d9ff15af7668756d60624dfa/yazi-shared/src/url/display.rs
yazi-shared/src/url/display.rs
use crate::{scheme::Encode, url::Url}; pub struct Display<'a>(pub Url<'a>); impl std::fmt::Display for Display<'_> { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { let (kind, loc) = (self.0.kind(), self.0.loc()); if kind.is_virtual() { Encode(self.0).fmt(f)?; } loc.display().fmt(f) ...
rust
MIT
3c39a326abaacb37d9ff15af7668756d60624dfa
2026-01-04T15:33:17.426354Z
false
sxyazi/yazi
https://github.com/sxyazi/yazi/blob/3c39a326abaacb37d9ff15af7668756d60624dfa/yazi-shared/src/url/mod.rs
yazi-shared/src/url/mod.rs
yazi_macro::mod_flat!(buf component components cov cow display encode like traits url);
rust
MIT
3c39a326abaacb37d9ff15af7668756d60624dfa
2026-01-04T15:33:17.426354Z
false
sxyazi/yazi
https://github.com/sxyazi/yazi/blob/3c39a326abaacb37d9ff15af7668756d60624dfa/yazi-shared/src/url/cow.rs
yazi-shared/src/url/cow.rs
use std::{borrow::Cow, hash::{Hash, Hasher}, path::PathBuf}; use anyhow::{Result, anyhow}; use serde::{Deserialize, Deserializer, Serialize}; use crate::{loc::{Loc, LocBuf}, path::{PathBufDyn, PathCow, PathDyn}, pool::SymbolCow, scheme::{AsScheme, Scheme, SchemeCow, SchemeKind, SchemeRef}, url::{AsUrl, Url, UrlBuf}};...
rust
MIT
3c39a326abaacb37d9ff15af7668756d60624dfa
2026-01-04T15:33:17.426354Z
false
sxyazi/yazi
https://github.com/sxyazi/yazi/blob/3c39a326abaacb37d9ff15af7668756d60624dfa/yazi-shared/src/url/components.rs
yazi-shared/src/url/components.rs
use std::{borrow::Cow, ffi::{OsStr, OsString}, iter::FusedIterator, ops::Not}; use crate::{loc::Loc, path, scheme::{Encode as EncodeScheme, SchemeCow, SchemeRef}, strand::{StrandBuf, StrandCow}, url::{Component, Encode as EncodeUrl, Url}}; #[derive(Clone)] pub struct Components<'a> { inner: path::Components...
rust
MIT
3c39a326abaacb37d9ff15af7668756d60624dfa
2026-01-04T15:33:17.426354Z
false
sxyazi/yazi
https://github.com/sxyazi/yazi/blob/3c39a326abaacb37d9ff15af7668756d60624dfa/yazi-shared/src/url/traits.rs
yazi-shared/src/url/traits.rs
use std::path::{Path, PathBuf}; use crate::{loc::Loc, url::{Url, UrlBuf, UrlCow}}; // --- AsUrl pub trait AsUrl { fn as_url(&self) -> Url<'_>; } impl AsUrl for Path { #[inline] fn as_url(&self) -> Url<'_> { Url::Regular(Loc::bare(self)) } } impl AsUrl for &Path { #[inline] fn as_url(&self) -> Url<'_> { (*self)...
rust
MIT
3c39a326abaacb37d9ff15af7668756d60624dfa
2026-01-04T15:33:17.426354Z
false
sxyazi/yazi
https://github.com/sxyazi/yazi/blob/3c39a326abaacb37d9ff15af7668756d60624dfa/yazi-shared/src/url/buf.rs
yazi-shared/src/url/buf.rs
use std::{borrow::Cow, fmt::{Debug, Formatter}, hash::{Hash, Hasher}, path::{Path, PathBuf}, str::FromStr}; use anyhow::Result; use serde::{Deserialize, Serialize}; use crate::{loc::LocBuf, path::{PathBufDyn, PathDynError, SetNameError}, pool::{InternStr, Pool, Symbol}, scheme::Scheme, strand::AsStrand, url::{AsUrl, ...
rust
MIT
3c39a326abaacb37d9ff15af7668756d60624dfa
2026-01-04T15:33:17.426354Z
false
sxyazi/yazi
https://github.com/sxyazi/yazi/blob/3c39a326abaacb37d9ff15af7668756d60624dfa/yazi-shared/src/url/component.rs
yazi-shared/src/url/component.rs
use std::path::PrefixComponent; use anyhow::Result; use crate::{path::{self, PathDynError}, scheme::SchemeRef, strand::Strand}; #[derive(Clone, Copy, Debug, PartialEq)] pub enum Component<'a> { Scheme(SchemeRef<'a>), Prefix(PrefixComponent<'a>), RootDir, CurDir, ParentDir, Normal(Strand<'a>), } impl<'a> From<...
rust
MIT
3c39a326abaacb37d9ff15af7668756d60624dfa
2026-01-04T15:33:17.426354Z
false
sxyazi/yazi
https://github.com/sxyazi/yazi/blob/3c39a326abaacb37d9ff15af7668756d60624dfa/yazi-shared/src/strand/view.rs
yazi-shared/src/strand/view.rs
use std::ffi::OsStr; // --- AsStrandView pub trait AsStrandView<'a, T> { fn as_strand_view(self) -> T; } impl<'a> AsStrandView<'a, &'a OsStr> for &'a OsStr { fn as_strand_view(self) -> &'a OsStr { self } } impl<'a> AsStrandView<'a, &'a OsStr> for &'a std::path::Path { fn as_strand_view(self) -> &'a OsStr { self.a...
rust
MIT
3c39a326abaacb37d9ff15af7668756d60624dfa
2026-01-04T15:33:17.426354Z
false
sxyazi/yazi
https://github.com/sxyazi/yazi/blob/3c39a326abaacb37d9ff15af7668756d60624dfa/yazi-shared/src/strand/like.rs
yazi-shared/src/strand/like.rs
use std::{borrow::Cow, ffi::OsStr, fmt::Display}; use crate::strand::{AsStrand, StrandBuf, StrandCow, StrandError, StrandKind}; // --- StrandLike pub trait StrandLike: AsStrand { fn as_os(&self) -> Result<&OsStr, StrandError> { self.as_strand().as_os() } fn as_utf8(&self) -> Result<&str, StrandError> { self.as_str...
rust
MIT
3c39a326abaacb37d9ff15af7668756d60624dfa
2026-01-04T15:33:17.426354Z
false
sxyazi/yazi
https://github.com/sxyazi/yazi/blob/3c39a326abaacb37d9ff15af7668756d60624dfa/yazi-shared/src/strand/kind.rs
yazi-shared/src/strand/kind.rs
use crate::{path::PathKind, scheme::SchemeKind}; #[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)] pub enum StrandKind { Utf8 = 0, Os = 1, Bytes = 2, } impl From<PathKind> for StrandKind { fn from(value: PathKind) -> Self { match value { PathKind::Os => Self::Os, PathKind::Unix => Se...
rust
MIT
3c39a326abaacb37d9ff15af7668756d60624dfa
2026-01-04T15:33:17.426354Z
false
sxyazi/yazi
https://github.com/sxyazi/yazi/blob/3c39a326abaacb37d9ff15af7668756d60624dfa/yazi-shared/src/strand/error.rs
yazi-shared/src/strand/error.rs
use thiserror::Error; // --- StrandError #[derive(Debug, Error)] pub enum StrandError { #[error("conversion to OS string failed")] AsOs, #[error("conversion to UTF-8 string failed")] AsUtf8, } impl From<StrandError> for std::io::Error { fn from(err: StrandError) -> Self { Self::other(err) } }
rust
MIT
3c39a326abaacb37d9ff15af7668756d60624dfa
2026-01-04T15:33:17.426354Z
false
sxyazi/yazi
https://github.com/sxyazi/yazi/blob/3c39a326abaacb37d9ff15af7668756d60624dfa/yazi-shared/src/strand/conversion.rs
yazi-shared/src/strand/conversion.rs
use std::{borrow::Cow, ffi::{OsStr, OsString}}; use crate::{path::{PathBufDyn, PathCow, PathDyn}, strand::{Strand, StrandBuf, StrandCow}, url::AsUrl}; // --- AsStrand pub trait AsStrand { fn as_strand(&self) -> Strand<'_>; } impl AsStrand for [u8] { fn as_strand(&self) -> Strand<'_> { Strand::Bytes(self) } } impl...
rust
MIT
3c39a326abaacb37d9ff15af7668756d60624dfa
2026-01-04T15:33:17.426354Z
false
sxyazi/yazi
https://github.com/sxyazi/yazi/blob/3c39a326abaacb37d9ff15af7668756d60624dfa/yazi-shared/src/strand/extensions.rs
yazi-shared/src/strand/extensions.rs
use crate::strand::{AsStrand, Strand, StrandBuf, StrandLike, ToStrand}; // --- StrandJoin pub trait AsStrandJoin { fn join(self, sep: Strand) -> StrandBuf; } impl<T> AsStrandJoin for T where T: IntoIterator, T::Item: AsStrand, { fn join(self, sep: Strand) -> StrandBuf { let mut kind = sep.kind(); let mut buf ...
rust
MIT
3c39a326abaacb37d9ff15af7668756d60624dfa
2026-01-04T15:33:17.426354Z
false
sxyazi/yazi
https://github.com/sxyazi/yazi/blob/3c39a326abaacb37d9ff15af7668756d60624dfa/yazi-shared/src/strand/strand.rs
yazi-shared/src/strand/strand.rs
use std::{borrow::Cow, ffi::OsStr, fmt::Display}; use anyhow::Result; use crate::{BytesExt, strand::{AsStrand, StrandBuf, StrandError, StrandKind}, wtf8::FromWtf8}; // --- Strand #[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialOrd)] pub enum Strand<'p> { Os(&'p OsStr), Utf8(&'p str), Bytes(&'p [u8]), } impl D...
rust
MIT
3c39a326abaacb37d9ff15af7668756d60624dfa
2026-01-04T15:33:17.426354Z
false
sxyazi/yazi
https://github.com/sxyazi/yazi/blob/3c39a326abaacb37d9ff15af7668756d60624dfa/yazi-shared/src/strand/mod.rs
yazi-shared/src/strand/mod.rs
yazi_macro::mod_flat!(buf conversion cow error extensions kind like strand view);
rust
MIT
3c39a326abaacb37d9ff15af7668756d60624dfa
2026-01-04T15:33:17.426354Z
false
sxyazi/yazi
https://github.com/sxyazi/yazi/blob/3c39a326abaacb37d9ff15af7668756d60624dfa/yazi-shared/src/strand/cow.rs
yazi-shared/src/strand/cow.rs
use std::{borrow::Cow, ffi::{OsStr, OsString}}; use anyhow::Result; use crate::strand::{AsStrand, Strand, StrandBuf, StrandKind}; pub enum StrandCow<'a> { Borrowed(Strand<'a>), Owned(StrandBuf), } impl Default for StrandCow<'_> { fn default() -> Self { Self::Borrowed(Strand::default()) } } impl From<OsString> f...
rust
MIT
3c39a326abaacb37d9ff15af7668756d60624dfa
2026-01-04T15:33:17.426354Z
false
sxyazi/yazi
https://github.com/sxyazi/yazi/blob/3c39a326abaacb37d9ff15af7668756d60624dfa/yazi-shared/src/strand/buf.rs
yazi-shared/src/strand/buf.rs
use std::{borrow::Cow, ffi::OsString, hash::{Hash, Hasher}}; use anyhow::Result; use crate::{path::PathDyn, strand::{AsStrand, Strand, StrandCow, StrandError, StrandKind}, wtf8::FromWtf8Vec}; // --- StrandBuf #[derive(Clone, Debug, Eq)] pub enum StrandBuf { Os(OsString), Utf8(String), Bytes(Vec<u8>), } impl Defa...
rust
MIT
3c39a326abaacb37d9ff15af7668756d60624dfa
2026-01-04T15:33:17.426354Z
false
sxyazi/yazi
https://github.com/sxyazi/yazi/blob/3c39a326abaacb37d9ff15af7668756d60624dfa/yazi-shared/src/scheme/ref.rs
yazi-shared/src/scheme/ref.rs
use std::{hash::Hash, ops::Deref}; use crate::{pool::InternStr, scheme::{AsScheme, Scheme, SchemeKind}}; #[derive(Clone, Copy, Debug)] pub enum SchemeRef<'a> { Regular { uri: usize, urn: usize }, Search { domain: &'a str, uri: usize, urn: usize }, Archive { domain: &'a str, uri: usize, urn: usize }, Sftp { domain...
rust
MIT
3c39a326abaacb37d9ff15af7668756d60624dfa
2026-01-04T15:33:17.426354Z
false
sxyazi/yazi
https://github.com/sxyazi/yazi/blob/3c39a326abaacb37d9ff15af7668756d60624dfa/yazi-shared/src/scheme/encode.rs
yazi-shared/src/scheme/encode.rs
use std::fmt::{self, Display}; use percent_encoding::{AsciiSet, CONTROLS, PercentEncode, percent_encode}; use crate::{scheme::SchemeKind, url::Url}; #[derive(Clone, Copy)] pub struct Encode<'a>(pub Url<'a>); impl<'a> From<crate::url::Encode<'a>> for Encode<'a> { fn from(value: crate::url::Encode<'a>) -> Self { Sel...
rust
MIT
3c39a326abaacb37d9ff15af7668756d60624dfa
2026-01-04T15:33:17.426354Z
false
sxyazi/yazi
https://github.com/sxyazi/yazi/blob/3c39a326abaacb37d9ff15af7668756d60624dfa/yazi-shared/src/scheme/kind.rs
yazi-shared/src/scheme/kind.rs
use anyhow::{Result, bail}; use crate::{BytesExt, scheme::{AsScheme, SchemeRef}}; #[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)] pub enum SchemeKind { Regular, Search, Archive, Sftp, } impl<T> From<T> for SchemeKind where T: AsScheme, { fn from(value: T) -> Self { match value.as_scheme() { SchemeRef::...
rust
MIT
3c39a326abaacb37d9ff15af7668756d60624dfa
2026-01-04T15:33:17.426354Z
false
sxyazi/yazi
https://github.com/sxyazi/yazi/blob/3c39a326abaacb37d9ff15af7668756d60624dfa/yazi-shared/src/scheme/mod.rs
yazi-shared/src/scheme/mod.rs
yazi_macro::mod_flat!(cow encode kind r#ref scheme traits);
rust
MIT
3c39a326abaacb37d9ff15af7668756d60624dfa
2026-01-04T15:33:17.426354Z
false
sxyazi/yazi
https://github.com/sxyazi/yazi/blob/3c39a326abaacb37d9ff15af7668756d60624dfa/yazi-shared/src/scheme/cow.rs
yazi-shared/src/scheme/cow.rs
use std::borrow::Cow; use anyhow::{Result, ensure}; use percent_encoding::percent_decode; use crate::{path::{PathCow, PathLike}, pool::{InternStr, SymbolCow}, scheme::{AsScheme, Scheme, SchemeKind, SchemeRef}, url::Url}; #[derive(Clone, Debug)] pub enum SchemeCow<'a> { Borrowed(SchemeRef<'a>), Owned(Scheme), } im...
rust
MIT
3c39a326abaacb37d9ff15af7668756d60624dfa
2026-01-04T15:33:17.426354Z
false