Trait easy_captcha::AbstractCaptcha
source · pub trait AbstractCaptcha: NewCaptcha {
type Error: Error + Debug + Send + Sync + 'static;
// Required methods
fn out(&mut self, out: impl Write) -> Result<(), Self::Error>;
fn get_chars(&mut self) -> Vec<char>;
fn base64(&mut self) -> Result<String, Self::Error>;
fn get_content_type(&mut self) -> String;
// Provided method
fn base64_with_head(&mut self, head: &str) -> Result<String, Self::Error> { ... }
}Expand description
验证码的抽象方法 Traits which a Captcha must implements.
Required Associated Types§
Required Methods§
sourcefn out(&mut self, out: impl Write) -> Result<(), Self::Error>
fn out(&mut self, out: impl Write) -> Result<(), Self::Error>
输出验证码到指定位置
Write the Captcha image to the specified place.
sourcefn get_chars(&mut self) -> Vec<char>
fn get_chars(&mut self) -> Vec<char>
获取验证码中的字符(即正确答案)
Get the characters (i.e. the correct answer) of the Captcha
sourcefn base64(&mut self) -> Result<String, Self::Error>
fn base64(&mut self) -> Result<String, Self::Error>
输出Base64编码。注意,返回值会带编码头(例如data:image/png;base64,),可以直接在浏览器中显示;如不需要编码头,
请使用base64_with_head方法并传入空参数以去除编码头。
Get the Base64 encoded image. Reminds: the returned Base64 strings will begin with an encoding head like
data:image/png;base64,, which make it possible to display in browsers directly. If you don’t need it, you may
use base64_with_head and pass a null string.
sourcefn get_content_type(&mut self) -> String
fn get_content_type(&mut self) -> String
获取验证码的MIME类型
Get the MIME Content type of the Captcha.
Provided Methods§
Object Safety§
This trait is not object safe.