Protocols

The following protocols are available globally.

  • Storable protocol

    The struct should conform to this protocol.

    sample

    struct Basic: Storable {
       let name: String
       let age: Float
       let number: Int

    init(warehouse: JSONWarehouse) { self.name = warehouse.get(name) ?? default self.age = warehouse.get(age) ?? 20.5 self.number = warehouse.get(number) ?? 10 } }

    See more

    Declaration

    Swift

    public protocol Storable
  • Default storable types

    Default types are Bool, String, Int, Float, Double, Date

    Declaration

    Swift

    public protocol StorableDefaultType
  • For enums with a raw value such as enum: Int, adding this protocol makes the enum storable.

    You should not need to implement any of the methods or properties in this protocol. Enums without a raw value e.g. with associated types are not supported.

    See more

    Declaration

    Swift

    public protocol StorableRawEnum: Storable