pub struct QrCodeConfig {
pub size: u32,
pub margin: u32,
pub foreground_color: [u8; 3],
pub background_color: [u8; 3],
pub error_correction_level: ErrorCorrectionLevel,
}Expand description
二维码配置 — 对齐 PHP Endroid\QrCode\QrCode
使用 Builder 模式构建配置,通过 QrCodeGenerator::with_config 创建生成器。
Fields§
§size: u32尺寸(像素,默认 200)
margin: u32边距(像素,默认 10)
foreground_color: [u8; 3]前景色(RGB,默认黑色 [0, 0, 0])
background_color: [u8; 3]背景色(RGB,默认白色 [255, 255, 255])
error_correction_level: ErrorCorrectionLevel容错级别(默认 Medium)
Implementations§
Source§impl QrCodeConfig
impl QrCodeConfig
Sourcepub fn new() -> Self
pub fn new() -> Self
创建默认配置
- 尺寸:200px
- 边距:10px
- 前景色:黑色
[0, 0, 0] - 背景色:白色
[255, 255, 255] - 容错级别:
Medium
Sourcepub fn with_margin(self, margin: u32) -> Self
pub fn with_margin(self, margin: u32) -> Self
设置边距(像素)
Sourcepub fn with_foreground_color(self, color: [u8; 3]) -> Self
pub fn with_foreground_color(self, color: [u8; 3]) -> Self
设置前景色(RGB)
Sourcepub fn with_background_color(self, color: [u8; 3]) -> Self
pub fn with_background_color(self, color: [u8; 3]) -> Self
设置背景色(RGB)
Sourcepub fn with_error_correction_level(self, level: ErrorCorrectionLevel) -> Self
pub fn with_error_correction_level(self, level: ErrorCorrectionLevel) -> Self
设置容错级别
Trait Implementations§
Source§impl Clone for QrCodeConfig
impl Clone for QrCodeConfig
Source§fn clone(&self) -> QrCodeConfig
fn clone(&self) -> QrCodeConfig
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for QrCodeConfig
impl Debug for QrCodeConfig
Auto Trait Implementations§
impl Freeze for QrCodeConfig
impl RefUnwindSafe for QrCodeConfig
impl Send for QrCodeConfig
impl Sync for QrCodeConfig
impl Unpin for QrCodeConfig
impl UnsafeUnpin for QrCodeConfig
impl UnwindSafe for QrCodeConfig
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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.