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 `ClientSender` and `ServerSender` types must be `#[repr(transparent)]` wrappers
10/// around `ClientSender<T>` and `ServerSender<T>` respectively.
11pub unsafe trait Protocol<T> {
12 /// The client sender for the protocol. It must be a `#[repr(transparent)]` wrapper around
13 /// `ClientSender<T>`.
14 type ClientSender;
15
16 /// The server sender for the protocol. It must be a `#[repr(transparent)]` wrapper around
17 /// `ServerSender<T>`.
18 type ServerSender;
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 response.
43pub enum Never {}