Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nodeEncodingStrategy #49

Closed
khoogheem opened this issue Dec 31, 2018 · 3 comments
Closed

nodeEncodingStrategy #49

khoogheem opened this issue Dec 31, 2018 · 3 comments
Assignees

Comments

@khoogheem
Copy link

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

@khoogheem
Copy link
Author

looks like pull #73 covers this

@MaxDesiatov
Copy link
Collaborator

@khoogheem Sorry for being late, as #73 was merged, did that resolve your issue?

@khoogheem
Copy link
Author

Yep that looks like it should..

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants