Skip to content

nodeEncodingStrategy #49

@khoogheem

Description

@khoogheem

Would like to see if it would be possible to look at extending the definition of the custom node encoding strategy. Or create another custom type

        case custom((Encodable.Type, Encoder) -> ((CodingKey) -> XMLEncoder.NodeEncoding))

What would be nice is if we can provide the Value.

        case custom((Encodable.Type, Encoder) -> ((Value) -> XMLEncoder.NodeEncoding))

here is the use case. Given a node type may have attributes using different keys names, I have created a AttributeBox.

public struct Attribute<Value> {

    public let value: Value

    public init(_ value: Value) {
        self.value = value
    }
}

extension Attribute: Encodable where Value: Encodable {
    public func encode(to encoder: Encoder) throws {
        try self.value.encode(to: encoder)
    }
}

extension Attribute: Decodable where Value: Decodable {
    public init(from decoder: Decoder) throws {
        self.init(try Value(from: decoder))
    }
}

So it would be nice to be able to say for Node Activity use the Type Attribute<Any> as the attribute

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions