• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2018 The Chromium OS Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 //! This module defines the protocol between `virtio-wayland` and `virtio-gpu` for sharing resources
6 //! that are backed by file descriptors.
7 
8 use std::fs::File;
9 use std::io::Result;
10 
11 use msg_on_socket_derive::MsgOnSocket;
12 use msg_socket::MsgSocket;
13 
14 #[derive(MsgOnSocket)]
15 pub enum ResourceRequest {
16     GetResource { id: u32 },
17 }
18 
19 #[derive(MsgOnSocket)]
20 pub enum ResourceResponse {
21     Resource(File),
22     Invalid,
23 }
24 
25 pub type ResourceRequestSocket = MsgSocket<ResourceRequest, ResourceResponse>;
26 pub type ResourceResponseSocket = MsgSocket<ResourceResponse, ResourceRequest>;
27 
pair() -> Result<(ResourceRequestSocket, ResourceResponseSocket)>28 pub fn pair() -> Result<(ResourceRequestSocket, ResourceResponseSocket)> {
29     msg_socket::pair()
30 }
31