-
Notifications
You must be signed in to change notification settings - Fork 6
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
Implement native lib0 encoding/decoding #7
Comments
Adding a couple of links here that Bartosz provided in discord (as much for my reference as anyone's). The focus of Bartosz also has details about v1 vs v2 serialization and what it means in the underlying Yrs code at https://bartoszsypytkowski.com/yrs-architecture/#serialization |
I see, that makes sense. But still, if I am getting it right, we can leverage |
I wanted to also point out the potential for using BinaryCodable (MIT licensed) for serializing arbitrary Swift types into a compact representation to pass through to the Rust/Yrs side of things. I haven't quite figured out how we might use
The obvious downside that I see is that if you were intentionally wanting to work cross-language, then having encoding in something akin to JSON or Protobuf's directly would be far more amenable to deserializing into relevant, mapped types within other languages. I don't know how easy, or even if it's possible, to decode the results of BinaryCodable into a type within another language. |
I've also taken a look at BinaryCodable – and I was keeping in mind that we might use it as an inspiration/foundation for idiomatically implementing lib0 in Swift rather than using it directly.
I think I have undercommunicated my reasoning behind the need for native lib0 in Swift. I will try to explain myself better:
Right now following steps are made to insert an element into the → How I think it could be reduced by implementing native → (1) – I believe this should be faster than JSON encoding (I could be wrong) |
Great detail, thank you! As a general flow, that makes a lot of sense, and I think I see where you're going but I'm not sure about the proposed flow using
The insert function being called with an arbitrary swift type makes sense - including the box-of-everything Once it's a bucket of bytes, then that totally makes sense - which is why I was thinking that BinaryCodable would be nice, because it was capable of the back-and-forth conversion from a specific swift type (as long as it conforms to the Maybe the assumption that I'm making is that In my glancing through the some Swift type that conforms to Is there an optimized path using lib0 that lets you: some Swift type that conforms to (Side note: I've been poking at a new (swift) Benchmarking library that might be fun to try and use to do some comparisons for speed of operations. It's package-benchmark, and looks reasonable easy to knock together quick benchmarks for "is this faster than that" kinds of questions) |
This can be useful in various ways:
For reference:
Note: there is no need to implement all of the functionality from lib0, only encoding/decoding parts are needed.
The text was updated successfully, but these errors were encountered: