ReadableWriteableDataSchema

Trait ReadableWriteableDataSchema 

Source
pub trait ReadableWriteableDataSchema<DS, AS, OS, Extended>: BuildableDataSchema<DS, AS, OS, Extended> {
    type ReadOnly: BuildableDataSchema<DS, AS, OS, Extended>;
    type WriteOnly: BuildableDataSchema<DS, AS, OS, Extended>;

    // Required methods
    fn read_only(self) -> Self::ReadOnly;
    fn write_only(self) -> Self::WriteOnly;
}
Expand description

An interface to specialize a read-only/write-only version of a DataSchema.

Some specializations of DataSchema can be set as read-only or write-only. When implemented, this allows a safe abstraction over these situations, avoiding conflicting states a compile-time.

§Notes

  • This trait should not be implemented directly, even if it is not sealed.

Required Associated Types§

Source

type ReadOnly: BuildableDataSchema<DS, AS, OS, Extended>

The read-only variant of the data schema builder.

Source

type WriteOnly: BuildableDataSchema<DS, AS, OS, Extended>

The write-only variant of the data schema builder.

Required Methods§

Source

fn read_only(self) -> Self::ReadOnly

Creates a read-only variant of the data schema builder.

§Examples
let thing = Thing::builder("Thing name")
    .finish_extend()
    .schema_definition("test", |b| {
        b.finish_extend()
            .integer()
            .minimum(5)
            .read_only()
            .maximum(10)
    })
    .build()
    .unwrap();

assert_eq!(
    serde_json::to_value(thing).unwrap(),
    json!({
        "@context": "https://www.w3.org/2022/wot/td/v1.1",
        "title": "Thing name",
        "schemaDefinitions": {
            "test": {
                "type": "integer",
                "readOnly": true,
                "writeOnly": false,
                "minimum": 5,
                "maximum": 10,
            }
        },
        "security": [],
        "securityDefinitions": {},
    })
);

The example using write_only is analogous. However, it is not possible to call both read_only and write_only on the same data schema building chain:

let thing = Thing::builder("Thing name")
    .finish_extend()
    .schema_definition("test", |b| {
        b.finish_extend().integer().read_only().write_only()
    })
    .build()
    .unwrap();
Source

fn write_only(self) -> Self::WriteOnly

Creates a write-only variant of the data schema builder.

See read_only for examples.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl<DS, AS, OS> ReadableWriteableDataSchema<DS, AS, OS, Extended> for EnumDataSchemaBuilder<DataSchemaBuilder<DS, AS, OS, Extended>>

Source§

impl<DS, AS, OS> ReadableWriteableDataSchema<DS, AS, OS, Extended> for EnumDataSchemaBuilder<PartialDataSchemaBuilder<DS, AS, OS, Extended>>

Source§

impl<DS, AS, OS> ReadableWriteableDataSchema<DS, AS, OS, Extended> for IntegerDataSchemaBuilder<DataSchemaBuilder<DS, AS, OS, Extended>>

Source§

impl<DS, AS, OS> ReadableWriteableDataSchema<DS, AS, OS, Extended> for IntegerDataSchemaBuilder<PartialDataSchemaBuilder<DS, AS, OS, Extended>>

Source§

impl<DS, AS, OS> ReadableWriteableDataSchema<DS, AS, OS, Extended> for NumberDataSchemaBuilder<DataSchemaBuilder<DS, AS, OS, Extended>>

Source§

impl<DS, AS, OS> ReadableWriteableDataSchema<DS, AS, OS, Extended> for NumberDataSchemaBuilder<PartialDataSchemaBuilder<DS, AS, OS, Extended>>

Source§

impl<DS, AS, OS> ReadableWriteableDataSchema<DS, AS, OS, Extended> for ObjectDataSchemaBuilder<DataSchemaBuilder<DS, AS, OS, Extended>, DS, AS, OS>

Source§

impl<DS, AS, OS> ReadableWriteableDataSchema<DS, AS, OS, Extended> for ObjectDataSchemaBuilder<PartialDataSchemaBuilder<DS, AS, OS, Extended>, DS, AS, OS>

Source§

impl<DS, AS, OS> ReadableWriteableDataSchema<DS, AS, OS, Extended> for StatelessDataSchemaBuilder<DataSchemaBuilder<DS, AS, OS, Extended>>

Source§

impl<DS, AS, OS> ReadableWriteableDataSchema<DS, AS, OS, Extended> for StatelessDataSchemaBuilder<PartialDataSchemaBuilder<DS, AS, OS, Extended>>

Source§

impl<DS, AS, OS> ReadableWriteableDataSchema<DS, AS, OS, Extended> for StringDataSchemaBuilder<DataSchemaBuilder<DS, AS, OS, Extended>>

Source§

impl<DS, AS, OS> ReadableWriteableDataSchema<DS, AS, OS, Extended> for StringDataSchemaBuilder<PartialDataSchemaBuilder<DS, AS, OS, Extended>>

Source§

impl<DS, AS, OS> ReadableWriteableDataSchema<DS, AS, OS, Extended> for TupleDataSchemaBuilder<DataSchemaBuilder<DS, AS, OS, Extended>, DS, AS, OS>

Source§

impl<DS, AS, OS> ReadableWriteableDataSchema<DS, AS, OS, Extended> for TupleDataSchemaBuilder<PartialDataSchemaBuilder<DS, AS, OS, Extended>, DS, AS, OS>

Source§

impl<DS, AS, OS> ReadableWriteableDataSchema<DS, AS, OS, Extended> for VecDataSchemaBuilder<DataSchemaBuilder<DS, AS, OS, Extended>, DS, AS, OS>

Source§

impl<DS, AS, OS> ReadableWriteableDataSchema<DS, AS, OS, Extended> for VecDataSchemaBuilder<PartialDataSchemaBuilder<DS, AS, OS, Extended>, DS, AS, OS>

Source§

impl<Other, CDS, DS, AS, OS, OtherInteractionAffordance, OtherPropertyAffordance> ReadableWriteableDataSchema<DS, AS, OS, Extended> for PropertyAffordanceBuilder<Other, CDS, OtherInteractionAffordance, OtherPropertyAffordance>
where Other: ExtendableThing<DataSchema = DS, ArraySchema = AS, ObjectSchema = OS>, CDS: ReadableWriteableDataSchema<DS, AS, OS, Extended>,

Source§

type ReadOnly = PropertyAffordanceBuilder<Other, <CDS as ReadableWriteableDataSchema<DS, AS, OS, Extended>>::ReadOnly, OtherInteractionAffordance, OtherPropertyAffordance>

Source§

type WriteOnly = PropertyAffordanceBuilder<Other, <CDS as ReadableWriteableDataSchema<DS, AS, OS, Extended>>::WriteOnly, OtherInteractionAffordance, OtherPropertyAffordance>