DataInputConvertible Protocol Reference
public protocol DataInputConvertible
Use this protocol to convert custom types to a valid DataInput.
This is particularly useful for types like enums or objects that can be safely represented with a Dictionary or an Array or a combination of nested Dictionaries and Arrays.
Everything that is not a Dictionary or an Array, including the elements contained in those collections, need to be one of the supported DataInput.
For cases in which you have only nested Arrays and Dictionaries that only contain valid DataInput,
implementing this protocol is not necessary and you can just wrap them with the prebuilt DataItem wrapper.
Although not preferable, you can make any Encodable type a DataInputConvertible by wrapping it with DataItem(serializing:).
Note that this method can fail, so you must handle the eventual EncodingError that can be thrown in case of failure.
-
toDataInput()Default implementationDefault Implementation
Declaration
Swift
func toDataInput() -> DataInput
-
toDataInput()Default implementationDefault Implementation
Declaration
Swift
func toDataInput() -> any DataInput