Add client transport abstraction#10
Conversation
|
One problem I'm having already with this approach is that having to mention the wayland transport type in multiple structs/function definitions when writing a client. so it's a bit hard to make a client that would work with multiple transport types or a client that can determine the transport type at runtime. |
You may write a type alias and use it everywhere.
If I understand correctly, virtio requires a very specific way to create pipes and shm buffers, so I'm not sure how feasible this is. But if a client supporting many transports is realistic, then either we should
By the way, I think we can remove the |
ac6ba19 to
0cf318f
Compare
0cf318f to
91fc3f0
Compare
91fc3f0 to
807428f
Compare
|
Note: I think most of the So for example impl<D, T> Connection<D, T> {
pub fn connect() -> Result<Self> where T: ClientTransport { ... }
#[doc(hidden)]
pub fn send_request(&mut self, iface: &'static Interface, request: Message) { .... }
pub fn flush(&mut self, mode: IoMode) -> io::Result<()> where T: Transport { ... }
} |
|
I adjusted the trait bound. Does that look correct? |
| fn fix_metadata( | ||
| &mut self, | ||
| plane_idx: usize, | ||
| width: u32, | ||
| height: u32, | ||
| format: u32, | ||
| ) -> Option<(u32, u32, u64)>; |
There was a problem hiding this comment.
- This function really needs some docs.
- This is very
wayrs-eglspecific. Maybe it should be moved to its owntrait EglTransport: ClientTransport?
There was a problem hiding this comment.
Sounds like a good idea, I'll refactor it and add some docs soon
|
How often do you call The transport can still be downcasted to a specific type, just with a small runtime check. |
|
that will be called every time a buffer is attached to query buffer metadata from the host. |
|
I took another look at this and since the overhead of doing a ioctl to get buffer metadata is much higher than accessing a trait object, I don't think there will be a big performance impact storing the transport as a trait object. I'm fine with this approach if it makes the api better. |
|
The performance overhead is basically zero and it shouldn't matter unless you call it thousands times per frame. By "how often" I meant how frequently it appears in the code, you would have to unwrap the option, which may be a bit annoying. I think not having a new generic would make the API generally better. However I'm not sure how to handle It doesn't matter that much, TBH. |
|
It should only be called when a buffer is attached to a surface. so not a lot of places. |
|
Let's drop the generic then |
|
sounds good, I'll refactor it when I get some time. |
|
It is really annoying that default generics are not allowed in functions. This means that if we want to drop the generic, we will have to have two versions of each One solution to this is to remove |
|
I've rebased this branch and applied some changes in #16. Could you take a look? |
I found a solution to this - having a builder type for Connection. Implemented in #17. I like this approach the most so far. |
|
Closing in favor of #17 |
I added a
ClientTransportto abstractconnectcall. All the tests still pass and egl example still works.But I'm not sure if all the changes I did are actually correct.