Skip to content

Commit 29dc233

Browse files
committed
docs
1 parent 5aafb2f commit 29dc233

File tree

1 file changed

+19
-2
lines changed

1 file changed

+19
-2
lines changed

src/lib.rs

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,10 @@ use std::{fmt::Debug, future::Future, io, marker::PhantomData, ops::Deref, resul
107107
///
108108
/// Individual enum variants can be annotated with the `#[rpc(...)]` attribute to specify channel types:
109109
///
110-
/// * `#[rpc(tx=SomeType)]`: Specify the transmitter/sender channel type (required)
111-
/// * `#[rpc(tx=SomeType, rx=OtherType)]`: Also specify a receiver channel type (optional)
110+
/// * `tx=SomeType`: Specify the transmitter/sender channel type (required)
111+
/// * `rx=OtherType`: Also specify a receiver channel type (optional)
112+
/// * `wrap=TypeName`: If set, a struct TypeName will be generated from the variant's fields, and the variant
113+
/// will be changed to have a single field of TypeName.
112114
///
113115
/// If `rx` is not specified, it defaults to `NoReceiver`.
114116
///
@@ -125,6 +127,21 @@ use std::{fmt::Debug, future::Future, io, marker::PhantomData, ops::Deref, resul
125127
/// }
126128
/// ```
127129
///
130+
/// With `wrap`:
131+
/// ```no_compile
132+
/// #[rpc_requests(message = StoreMessage)]
133+
/// enum StoreProtocol {
134+
/// #[rpc(wrap=GetRequest, tx=oneshot::Sender<Value>)]
135+
/// Get(Uuid),
136+
/// #[rpc(wrap=SetRequest, tx=oneshot::Sender<()>)]
137+
/// Set { id: Uuid, value: Value }
138+
/// }
139+
///
140+
/// let client = Client::<StoreProtocol>::local(tx);
141+
/// client.rpc(SetRequest { id, value }).await?;
142+
/// let value = client.rpc(GetRequest(id)).await?;
143+
/// ```
144+
///
128145
/// With type aliases:
129146
/// ```no_compile
130147
/// #[rpc_requests(message = ComputeMessage, alias = "Msg")]

0 commit comments

Comments
 (0)