pub enum StorageDriver {
Local(LocalStorageEngine),
Aliyun(AliyunStorageEngine),
Qcloud(QcloudStorageEngine),
Qiniu(QiniuStorageEngine),
S3(S3StorageEngine),
}Expand description
存储驱动 — 对齐 PHP storage\Driver
PHP 第 12-23 行:构造方法实例化引擎
PHP 第 108-116 行:getEngineClass 工厂方法
Rust 端使用枚举分发,避免动态分发开销。
Variants§
Local(LocalStorageEngine)
本地存储引擎
Aliyun(AliyunStorageEngine)
阿里云 OSS 引擎
Qcloud(QcloudStorageEngine)
腾讯云 COS 引擎
Qiniu(QiniuStorageEngine)
七牛云 Kodo 引擎
S3(S3StorageEngine)
AWS S3 兼容引擎
Implementations§
Source§impl StorageDriver
impl StorageDriver
Sourcepub fn new(kind: StorageEngineKind, config: EngineConfig) -> Self
pub fn new(kind: StorageEngineKind, config: EngineConfig) -> Self
创建存储驱动 — 对齐 PHP Driver::__construct($config, $storage = 'qcloud')
PHP 第 18-23 行:
public function __construct($config, $storage = 'qcloud') {
$this->config = $config;
$this->engine = $this->getEngineClass($storage);
}Sourcepub async fn upload(&mut self) -> Result<Option<String>, UploadError>
pub async fn upload(&mut self) -> Result<Option<String>, UploadError>
执行上传 — 对齐 PHP Driver::upload()
Sourcepub async fn delete(&mut self, file_name: &str) -> Result<bool, UploadError>
pub async fn delete(&mut self, file_name: &str) -> Result<bool, UploadError>
执行删除 — 对齐 PHP Driver::delete($fileName)
Sourcepub fn file_info(&self) -> Option<&UploadFileInfo>
pub fn file_info(&self) -> Option<&UploadFileInfo>
获取文件信息 — 对齐 PHP Driver::getFileInfo()
Sourcepub fn set_upload_file(
&mut self,
file: &UploadedFile,
) -> Result<(), UploadError>
pub fn set_upload_file( &mut self, file: &UploadedFile, ) -> Result<(), UploadError>
设置上传文件 — 对齐 PHP Driver::setUploadFile($name)
Sourcepub fn set_upload_file_by_real(
&mut self,
file_path: &Path,
extension: &str,
) -> Result<(), UploadError>
pub fn set_upload_file_by_real( &mut self, file_path: &Path, extension: &str, ) -> Result<(), UploadError>
设置内部上传文件 — 对齐 PHP Driver::setUploadFileByReal($filePath, $extension)
Sourcepub fn is_internal(&self) -> bool
pub fn is_internal(&self) -> bool
是否内部上传
Sourcepub fn kind(&self) -> StorageEngineKind
pub fn kind(&self) -> StorageEngineKind
获取引擎类型
Auto Trait Implementations§
impl Freeze for StorageDriver
impl RefUnwindSafe for StorageDriver
impl Send for StorageDriver
impl Sync for StorageDriver
impl Unpin for StorageDriver
impl UnsafeUnpin for StorageDriver
impl UnwindSafe for StorageDriver
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pointable for T
impl<T> Pointable for T
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
Checks if
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
Use with care! Same as
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self to the equivalent element of its superset.