Skip to content

Commit f4056aa

Browse files
committed
mctp: Adjust doc comments
- Make the doc comments on the methods of the async types consistently refer to the methods of the sync types, and remove the `allow(missing_docs)`. - Clarify the comments about the return type on the `recv` methods, to better explain what happens with `buf`, and to get the tuple ordering right. Signed-off-by: Nicholas Nethercote <n.nethercote@gmail.com>
1 parent 0e51090 commit f4056aa

File tree

1 file changed

+20
-44
lines changed

1 file changed

+20
-44
lines changed

mctp/src/lib.rs

Lines changed: 20 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -259,8 +259,9 @@ pub trait ReqChannel {
259259

260260
/// Blocking receive
261261
///
262-
/// Returns a filled slice of `buf`, MCTP message type, and IC bit.
263-
/// Will fail if used without a prior call to `send` or `send_vectored`.
262+
/// Returns the MCTP message type, the IC bit, and the filled subslice of
263+
/// `buf`. Will fail if used without a prior call to `send` or
264+
/// `send_vectored`.
264265
fn recv<'f>(
265266
&mut self,
266267
buf: &'f mut [u8],
@@ -270,16 +271,17 @@ pub trait ReqChannel {
270271
fn remote_eid(&self) -> Eid;
271272
}
272273

273-
#[allow(missing_docs)]
274-
/// Async equivalent of [`ReqChannel`]
274+
/// Async equivalent of [`ReqChannel`].
275275
pub trait AsyncReqChannel {
276+
/// Async equivalent of [`ReqChannel::send_vectored`].
276277
fn send_vectored(
277278
&mut self,
278279
typ: MsgType,
279280
integrity_check: MsgIC,
280281
bufs: &[&[u8]],
281282
) -> impl Future<Output = Result<()>>;
282283

284+
/// Async equivalent of [`ReqChannel::send`].
283285
fn send(
284286
&mut self,
285287
typ: MsgType,
@@ -288,12 +290,13 @@ pub trait AsyncReqChannel {
288290
async move { self.send_vectored(typ, MsgIC(false), &[buf]).await }
289291
}
290292

293+
/// Async equivalent of [`ReqChannel::recv`].
291294
fn recv<'f>(
292295
&mut self,
293296
buf: &'f mut [u8],
294297
) -> impl Future<Output = Result<(MsgType, MsgIC, &'f mut [u8])>>;
295298

296-
/// Return the remote Endpoint ID
299+
/// Async equivalent of [`ReqChannel::remote_eid`].
297300
fn remote_eid(&self) -> Eid;
298301
}
299302

@@ -342,49 +345,29 @@ pub trait RespChannel {
342345
fn req_channel(&self) -> Result<Self::ReqChannel>;
343346
}
344347

345-
#[allow(missing_docs)]
346348
/// Async equivalent of [`RespChannel`]
347349
pub trait AsyncRespChannel {
348-
/// `ReqChannel` type returned by [`req_channel`](Self::req_channel)
350+
/// Async equivalent of [`RespChannel::ReqChannel`].
349351
type ReqChannel<'a>: AsyncReqChannel
350352
where
351353
Self: 'a;
352354

353-
/// Send a slice of buffers to this endpoint, blocking.
354-
///
355-
/// The slice of buffers will be sent as a single message
356-
/// (as if concatenated). Accepting multiple buffers allows
357-
/// higher level protocols to more easily append their own
358-
/// protocol headers to a payload without needing extra
359-
/// buffer allocations.
360-
///
361-
/// The sent message type will match that received by the
362-
/// corresponding `AsyncListener`.
363-
///
364-
/// The `integrity_check` argument is the MCTP header IC bit.
355+
/// Async equivalent of [`RespChannel::send_vectored`].
365356
fn send_vectored(
366357
&mut self,
367358
integrity_check: MsgIC,
368359
bufs: &[&[u8]],
369360
) -> impl Future<Output = Result<()>>;
370361

371-
/// Send a message to this endpoint, blocking.
372-
///
373-
/// Transport implementations will typically use the trait provided method
374-
/// that calls [`send_vectored`](Self::send_vectored).
375-
///
376-
/// The sent message type will match that received by the
377-
/// corresponding `AsyncListener`.
378-
///
379-
/// IC bit is unset.
362+
/// Async equivalent of [`RespChannel::send`].
380363
fn send(&mut self, buf: &[u8]) -> impl Future<Output = Result<()>> {
381364
async move { self.send_vectored(MsgIC(false), &[buf]).await }
382365
}
383366

384-
/// Return the remote Endpoint ID
367+
/// Async equivalent of [`RespChannel::remote_eid`].
385368
fn remote_eid(&self) -> Eid;
386369

387-
/// Constructs a new ReqChannel to the same MCTP endpoint as this RespChannel.
370+
/// Async equivalent of [`RespChannel::req_channel`].
388371
// TODO: should this be async?
389372
fn req_channel(&self) -> Result<Self::ReqChannel<'_>>;
390373
}
@@ -394,38 +377,31 @@ pub trait AsyncRespChannel {
394377
/// This will receive messages with TO=1. Platform-specific constructors
395378
/// will specify the MCTP message parameters (eg, message type) to listen for.
396379
pub trait Listener {
397-
/// `RespChannel` type returned by this `Listener`
380+
/// `RespChannel` type returned by this `Listener`.
398381
type RespChannel<'a>: RespChannel
399382
where
400383
Self: 'a;
401384

402385
/// Blocking receive
403386
///
404-
/// This receives a single MCTP message matched by the `Listener`.
405-
/// Returns a filled slice of `buf`, `RespChannel`, and IC bit `MsgIC`.
406-
///
407-
/// The returned `RespChannel` should be used to send responses to the
387+
/// This receives a single MCTP message matched by the `Listener`. Returns
388+
/// the MCTP message type, the IC bit, the filled subslice of `buf`, and
389+
/// the response channel that should be used to send responses to the
408390
/// request.
409391
fn recv<'f>(
410392
&mut self,
411393
buf: &'f mut [u8],
412394
) -> Result<(MsgType, MsgIC, &'f mut [u8], Self::RespChannel<'_>)>;
413395
}
414396

415-
#[allow(missing_docs)]
416-
/// Async equivalent of [`Listener`]
397+
/// Async equivalent of [`Listener`].
417398
pub trait AsyncListener {
418-
/// `RespChannel` type returned by this `Listener`
399+
/// Async equivalent of [`Listener::RespChannel`].
419400
type RespChannel<'a>: AsyncRespChannel
420401
where
421402
Self: 'a;
422403

423-
/// Blocking receive
424-
///
425-
/// This receives a single MCTP message matched by the `Listener`.
426-
/// Returns a filled slice of `buf`, `RespChannel`, and IC bit `MsgIC`.
427-
///
428-
/// The returned `RespChannel` should be used to send responses.
404+
/// Async equivalent of [`Listener::recv`].
429405
fn recv<'f>(
430406
&mut self,
431407
buf: &'f mut [u8],

0 commit comments

Comments
 (0)