drivers

package
v0.2.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 6, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ErrorContext

func ErrorContext(err error, op string) string

Types

type CommandError

type CommandError struct {
	Cmd string
	Err error
}

func (*CommandError) Error

func (e *CommandError) Error() string

func (*CommandError) Unwrap

func (e *CommandError) Unwrap() error

type Driver

type Driver interface {
	// Type 返回驱动类型标识
	// 例如: "smb", "sshfs"
	Type() string

	// Mount 执行挂载操作
	// ctx: 上下文,用于取消和超时控制
	// entry: 挂载条目配置
	Mount(ctx context.Context, entry *config.MountEntry) error

	// Unmount 执行卸载操作
	// ctx: 上下文
	// entry: 挂载条目配置
	Unmount(ctx context.Context, entry *config.MountEntry) error

	// Status 检查挂载状态
	// 返回挂载状态详情
	Status(ctx context.Context, entry *config.MountEntry) (*MountStatus, error)

	// Validate 验证配置是否有效
	// 在加载配置时调用,提前发现配置错误
	Validate(entry *config.MountEntry) error

	// NeedsSudo 返回该驱动是否需要 root 权限执行挂载/卸载
	NeedsSudo() bool
}

Driver 驱动接口,所有挂载驱动必须实现

type DriverError

type DriverError struct {
	// Driver 驱动类型
	Driver string

	// Op 操作类型: mount, unmount, status
	Op string

	// Entry 挂载条目名称
	Entry string

	// Err 原始错误
	Err error
}

DriverError 驱动操作错误

func (*DriverError) CoreMessage

func (e *DriverError) CoreMessage() string

func (*DriverError) Error

func (e *DriverError) Error() string

func (*DriverError) Unwrap

func (e *DriverError) Unwrap() error

type DriverRegistry

type DriverRegistry struct {
	// contains filtered or unexported fields
}

DriverRegistry 驱动注册表

func NewRegistry

func NewRegistry() *DriverRegistry

NewRegistry 创建新的驱动注册表

func (*DriverRegistry) Detect

func (r *DriverRegistry) Detect(entry *config.MountEntry) (Driver, error)

Detect 根据type字段返回对应的驱动

func (*DriverRegistry) Get

func (r *DriverRegistry) Get(driverType string) (Driver, bool)

Get 根据类型获取驱动

func (*DriverRegistry) List

func (r *DriverRegistry) List() []string

List 返回所有已注册的驱动类型

func (*DriverRegistry) Register

func (r *DriverRegistry) Register(d Driver)

Register 注册驱动

type Manager

type Manager struct {
	// contains filtered or unexported fields
}

Manager 驱动管理器

func NewManager

func NewManager(cfg *config.Config) *Manager

NewManager 创建新的驱动管理器

func (*Manager) DetectDriver

func (m *Manager) DetectDriver(entry *config.MountEntry) (Driver, error)

DetectDriver 自动检测条目对应的驱动

func (*Manager) GetDriver

func (m *Manager) GetDriver(driverType string) (Driver, error)

GetDriver 根据类型获取驱动

func (*Manager) GetMount

func (m *Manager) GetMount(name string) (*config.MountEntry, error)

GetMount 获取指定名称的挂载条目

func (*Manager) GetMounts

func (m *Manager) GetMounts() []config.MountEntry

GetMounts 获取所有挂载条目

func (*Manager) GetRegisteredDrivers

func (m *Manager) GetRegisteredDrivers() []string

GetRegisteredDrivers 获取所有已注册的驱动类型

func (*Manager) Mount

func (m *Manager) Mount(ctx context.Context, entryName string) error

Mount 挂载指定条目

func (*Manager) RefreshAllStatus

func (m *Manager) RefreshAllStatus(ctx context.Context) error

RefreshAllStatus 刷新所有条目的挂载状态

func (*Manager) RegisterDriver

func (m *Manager) RegisterDriver(d Driver)

RegisterDriver 注册驱动

func (*Manager) Status

func (m *Manager) Status(ctx context.Context, entryName string) (*MountStatus, error)

Status 获取条目状态

func (*Manager) Unmount

func (m *Manager) Unmount(ctx context.Context, entryName string) error

Unmount 卸载指定条目

type MountStatus

type MountStatus struct {
	// Mounted 是否已挂载
	Mounted bool

	// Message 状态描述信息
	Message string

	// Details 驱动特定的详细信息
	// 例如:SMB可能包含服务器地址,SSHFS可能包含连接状态
	Details map[string]string
}

MountStatus 挂载状态信息

type TunnelError

type TunnelError struct {
	Host string
	Err  error
}

func (*TunnelError) Error

func (e *TunnelError) Error() string

func (*TunnelError) Unwrap

func (e *TunnelError) Unwrap() error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL