fidl_next_bind/
protocol.rs

1// Copyright 2024 The Fuchsia 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/// A FIDL protocol.
6///
7/// # Safety
8///
9/// The associated `Client` and `Server` types must be `#[repr(transparent)]`
10/// wrappers around `Client<T>` and `Server<T>` respectively.
11pub unsafe trait Protocol<T> {
12    /// The client for the protocol. It must be a `#[repr(transparent)]` wrapper
13    /// around `Client<T>`.
14    type Client;
15
16    /// The server for the protocol. It must be a `#[repr(transparent)]` wrapper
17    /// around `Server<T>`.
18    type Server;
19}
20
21/// A discoverable protocol.
22pub trait Discoverable {
23    /// The service name to use to connect to this discoverable protocol.
24    const PROTOCOL_NAME: &'static str;
25}
26
27/// A method of a protocol.
28pub trait Method {
29    /// The ordinal associated with the method;
30    const ORDINAL: u64;
31
32    /// The protocol the method is a member of.
33    type Protocol;
34
35    /// The request payload for the method.
36    type Request;
37
38    /// The response payload for the method.
39    type Response;
40}
41
42/// The request or response type of a method which does not have a request or
43/// response.
44pub enum Never {}