I don't know about Swift, but in Objective-C, couldn't you use something like NSKeyedArchiver for serializing a complex object graph to a byte string? It's not safe if you don't trust the input, but if you do, I'm not sure why you'd go to the effort of reinventing this particular wheel, besides it being fun. Though maybe the serialization and deserialization are not the interesting parts here.
That still leaves you with the problem of wiring up the request -> response types manually, doesn't it? The serialization format isn't that important in this case.
Oh, I see, so the value of the DSL is in handling the pair of request and response. I suppose that makes sense.
There is probably a way you could accomplish this with generically serialized objects that have virtual methods, but it wouldn't be as neat or type-safe.
Yes, although I've never used capnproto, I believe the approach it takes is similar: you define your schema, it generates code to do the serialization and to handle the RPCs.
I don't know about Swift, but in Objective-C, couldn't you use something like NSKeyedArchiver for serializing a complex object graph to a byte string? It's not safe if you don't trust the input, but if you do, I'm not sure why you'd go to the effort of reinventing this particular wheel, besides it being fun. Though maybe the serialization and deserialization are not the interesting parts here.
That still leaves you with the problem of wiring up the request -> response types manually, doesn't it? The serialization format isn't that important in this case.
Oh, I see, so the value of the DSL is in handling the pair of request and response. I suppose that makes sense.
There is probably a way you could accomplish this with generically serialized objects that have virtual methods, but it wouldn't be as neat or type-safe.
Swift has Codable which seems to work for this, but I haven't used it in forever.
Can captain proto be used there?
Yes, although I've never used capnproto, I believe the approach it takes is similar: you define your schema, it generates code to do the serialization and to handle the RPCs.
That or regular protobuf would be my go-to for this. Capnproto is faster, but idk if there are more limitations as a result.