pub enum FileValidateError {
SizeExceeded {
actual: u64,
max: u64,
msg: String,
},
ExtNotAllowed {
ext: String,
allowed: Vec<String>,
msg: String,
},
MimeNotAllowed {
mime: String,
allowed: Vec<String>,
msg: String,
},
Io(Error),
MimeDetect(String),
}Expand description
文件校验错误 — 对齐 PHP Driver::validate 校验失败
PHP 行为:校验失败时抛出异常,Driver::validate 捕获后设置 $this->engine->error 并返回 false。
Rust 端使用 Result<(), FileValidateError> 表达校验失败。
Variants§
SizeExceeded
文件大小超过限制(对齐 PHP fileSize 规则失败)
错误消息对齐 PHP Driver.php 第 35 行:'最大可上传2M图片'
ExtNotAllowed
扩展名不允许(对齐 PHP fileExt 规则失败)
错误消息对齐 PHP Driver.php 第 36 行:'只能上传jpg,jpeg,png,gif,bmp格式图片'
MimeNotAllowed
MIME 类型不允许(对齐 PHP fileMime 规则失败)
错误消息对齐 PHP Driver.php 第 37 行:'只能上传jpg,jpeg,png,gif,bmp格式图片'
Io(Error)
获取文件信息失败(IO 错误)
MimeDetect(String)
获取 MIME 失败(对齐 PHP finfo_file 失败)
Trait Implementations§
Source§impl Debug for FileValidateError
impl Debug for FileValidateError
Source§impl Display for FileValidateError
impl Display for FileValidateError
Source§impl Error for FileValidateError
impl Error for FileValidateError
Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
Returns the lower-level source of this error, if any. Read more
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
👎Deprecated since 1.42.0:
use the Display impl or to_string()
Auto Trait Implementations§
impl !RefUnwindSafe for FileValidateError
impl !UnwindSafe for FileValidateError
impl Freeze for FileValidateError
impl Send for FileValidateError
impl Sync for FileValidateError
impl Unpin for FileValidateError
impl UnsafeUnpin for FileValidateError
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.