pub struct ExampleBuilder;Expand description
基于 Schema 生成示例值的生成器
Implementations§
Source§impl ExampleBuilder
impl ExampleBuilder
Sourcepub fn from_schema(schema: &Schema) -> Value
pub fn from_schema(schema: &Schema) -> Value
根据 Schema 生成示例值
- 对象:递归生成所有字段的示例
- 数组:生成单元素数组
- 引用:返回 null(需调用方解析引用)
- 基本类型:根据 type/format 生成合理的默认值
Sourcepub fn from_object(obj: &ObjectType) -> Value
pub fn from_object(obj: &ObjectType) -> Value
根据对象 Schema 生成示例对象
Sourcepub fn from_primitive(p: &PrimitiveSchema) -> Value
pub fn from_primitive(p: &PrimitiveSchema) -> Value
根据基本类型 Schema 生成示例值
Auto Trait Implementations§
impl Freeze for ExampleBuilder
impl RefUnwindSafe for ExampleBuilder
impl Send for ExampleBuilder
impl Sync for ExampleBuilder
impl Unpin for ExampleBuilder
impl UnsafeUnpin for ExampleBuilder
impl UnwindSafe for ExampleBuilder
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