Skip to content

Commit 873768d

Browse files
committed
Added doc comments.
1 parent 1f2d384 commit 873768d

File tree

2 files changed

+23
-4
lines changed

2 files changed

+23
-4
lines changed

api/swimos_agent_protocol/src/model.rs

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -149,15 +149,15 @@ impl<T> From<StoreResponse<T>> for LaneResponse<T> {
149149
/// Message type for agents to send commands to the runtime.
150150
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
151151
pub enum CommandMessage<S, T> {
152-
Register {
153-
address: Address<S>,
154-
id: u16,
155-
},
152+
/// Register an endpoint so that it can be referred to by an integer ID.
153+
Register { address: Address<S>, id: u16 },
154+
/// Send an message to explicit address.
156155
Addressed {
157156
target: Address<S>,
158157
command: T,
159158
overwrite_permitted: bool,
160159
},
160+
/// Send a message to an endpoint that was registered with a register message.
161161
Registered {
162162
target: u16,
163163
command: T,
@@ -166,6 +166,8 @@ pub enum CommandMessage<S, T> {
166166
}
167167

168168
impl<S, T> CommandMessage<S, T> {
169+
/// Send a message to an explicit endpoint.
170+
///
169171
/// # Arguments
170172
/// * `address` - The target lane for the command.
171173
/// * `command` - The body of the command message.
@@ -181,10 +183,24 @@ impl<S, T> CommandMessage<S, T> {
181183
}
182184
}
183185

186+
/// Register an integer ID for a lane endpoint.
187+
///
188+
/// # Arguments
189+
/// * `address` - The target lane to register.
190+
/// * `id` - The ID to assign to the address.
184191
pub fn register(address: Address<S>, id: u16) -> Self {
185192
CommandMessage::Register { address, id }
186193
}
187194

195+
/// Send a message to an pre-registered endpoint.
196+
///
197+
/// # Arguments
198+
/// * `target` - The registered ID.
199+
/// * `command` - The body of the command message.
200+
/// * `overwrite_permitted` - Controls the behaviour of command handling in the case of back-pressure.
201+
/// If this is true, the command maybe be overwritten by a subsequent command to the same target (and so
202+
/// will never be sent). If false, the command will be queued instead. This is a user specifiable parameter
203+
/// in the API.
188204
pub fn registered(target: u16, command: T, overwrite_permitted: bool) -> Self {
189205
CommandMessage::Registered {
190206
target,

api/swimos_api/src/error/mod.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,10 +104,13 @@ pub enum AgentRuntimeError {
104104
Terminated,
105105
}
106106

107+
/// Error type for registering point to point command channels.
107108
#[derive(Error, Debug, Clone, Copy, PartialEq, Eq)]
108109
pub enum CommanderRegistrationError {
110+
/// The registration could not be completed because the agent is stopping.
109111
#[error(transparent)]
110112
RuntimeError(#[from] AgentRuntimeError),
113+
/// The limit on the number of registrations for the agent was exceeded.
111114
#[error("Too many commander IDs were requested for the agent.")]
112115
CommanderIdOverflow,
113116
}

0 commit comments

Comments
 (0)