Structure
LeafData
LeafData is a “pseudo-protocol” wrapping the physically storable Swift data types Leaf can use directlystruct LeafData
Overview
(Bool, Int, Double, String, Array, Dictionary, Data)are the inherent root types supported, all of which may also be representable asOptionalvalues.NaturalTypepresents these cases plusVoidas a case for functionalLeafSymbolsnilis creatable, but only within context of a root base type - eg,.nil(.bool)==Bool?
Topics
Operators
static func == (LeafData, LeafData) -> BoolReturns a Boolean value indicating whether two values are equal.
Initializers
init(any LeafDataRepresentable)init(arrayLiteral: LeafData...)Creates an instance initialized with the given elements.init(booleanLiteral: BooleanLiteralType)Creates an instance initialized to the given Boolean value.init(dictionaryLiteral: (String, LeafData)...)Creates an instance initialized with the given key-value pairs.init(floatLiteral: FloatLiteralType)Creates an instance initialized to the specified floating-point value.init(integerLiteral: IntegerLiteralType)Creates an instance initialized to the specified integer value.init(nilLiteral: ())Creates an instance initialized withnil.init(stringLiteral: StringLiteralType)Creates an instance initialized to the given string value.
Instance Properties
var array: [LeafData]?Attempts to convert to[LeafData]or returnsnil.var bool: Bool?Attempts to convert toBoolor returnsnil.var celf: LeafData.NaturalTypeThe case-self identityvar data: Data?Attempts to convert toDataor returnsnil.var description: StringA textual representation of this instance.var dictionary: [String : LeafData]?Attempts to convert to[String: LeafData]or returnsnil.var double: Double?Attempts to convert toDoubleor returnsnil.var hasUniformType: Bool?Returnstrueif the object has a single uniform typevar int: Int?Attempts to convert toIntor returnsnil.var isCollection: BoolReturnstrueif the data can hold other data - we don’t considerOptionalfor this purposevar isNil: BoolReturnstrueif the data isnilorvoid.var short: Stringvar string: String?Attempts to convert toStringor returnsnil.var uniformType: LeafData.NaturalType?Returns the uniform type of the object, or nil if it is a non-uniform container
Instance Methods
func cast(to: LeafData.NaturalType) -> LeafDatafunc coerce(to: LeafData.NaturalType) -> LeafDatafunc isCastable(to: LeafData.NaturalType) -> BoolReturnstrueif concrete object can be exactly or losslessly cast to a second typefunc isCoercible(to: LeafData.NaturalType) -> BoolReturnstrueif concrete object is potentially directly coercible to a second type in some way
Type Properties
static var trueNil: LeafDataFor convenience,trueNilis stored as.optional(nil, .void)
Type Methods
static func array([LeafData]?) -> LeafDataCreates a newLeafDatafrom[LeafData].static func bool(Bool?) -> LeafDataCreates a newLeafDatafrom aBool.static func data(Data?) -> LeafDataCreates a newLeafDatafromData.static func dictionary([String : LeafData]?) -> LeafDataCreates a newLeafDatafrom[String: LeafData].static func double(Double?) -> LeafDataCreates a newLeafDatafrom aDouble.static func int(Int?) -> LeafDataCreates a newLeafDatafrom amInt.static func `nil`(LeafData.NaturalType) -> LeafDataCreates a newLeafDataforOptional<LeafData>static func string(String?) -> LeafDataCreates a newLeafDatafrom aString.
Enumerations
enum NaturalTypeThe concrete instantiable object types for aLeafData
Relationships
Conforms To
Swift.CustomStringConvertibleSwift.EquatableSwift.ExpressibleByArrayLiteralSwift.ExpressibleByBooleanLiteralSwift.ExpressibleByDictionaryLiteralSwift.ExpressibleByExtendedGraphemeClusterLiteralSwift.ExpressibleByFloatLiteralSwift.ExpressibleByIntegerLiteralSwift.ExpressibleByNilLiteralSwift.ExpressibleByStringLiteralSwift.ExpressibleByUnicodeScalarLiteralSwift.SendableSwift.SendableMetatype