auth/kind.rs

yazi · yazi-shared/src/auth/kind.rs · rust · MIT
auth, tag:embed-classified

Enum mapping authentication kinds to path kinds. Use for auth path handling.

// Source: https://github.com/sxyazi/yazi | License: MIT | Copyright 2023 - sxyazi
// Provided via justclaw.it.com; keep this notice with the code.
use anyhow::bail;
use serde::Deserialize;
use strum::{EnumIs, EnumString, IntoStaticStr};

use crate::path::PathKind;

#[derive(
	Clone, Copy, Debug, Default, Deserialize, EnumIs, EnumString, Eq, Hash, IntoStaticStr, PartialEq,
)]
#[serde(rename_all = "lowercase")]
#[strum(serialize_all = "lowercase")]
pub enum AuthKind {
	#[default]
	Regular,
	Mount,
	Hub,
	Scope,
	Sftp,
	View,
}

impl TryFrom<AuthKind> for PathKind {
	type Error = anyhow::Error;

	fn try_from(kind: AuthKind) -> Result<Self, Self::Error> {
		match kind {
			AuthKind::Regular | AuthKind::Mount | AuthKind::Hub => Ok(Self::Os),
			AuthKind::Scope | AuthKind::Sftp => Ok(Self::Unix

... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search for more like it.

Get a free API key