Skip to content

Commit

Permalink
deny missing documentation and implement missing docs
Browse files Browse the repository at this point in the history
  • Loading branch information
ystreet committed Nov 14, 2024
1 parent eb852cb commit 699d482
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -318,16 +318,21 @@ impl<'a, 'b> RtpPacketBuilder<&'a [u8], &'b [u8]> {

/// Trait to provide the length of a piece of data in bytes.
pub trait PayloadLength {
/// The length of the data in bytes.
fn len(&self) -> usize;
/// Whether the data contains any bytes.
fn is_empty(&self) -> bool {
self.len() != 0
}
}

/// Trait to write an RTP packet into and/or from custom data types.
pub trait RtpPacketWriter {
/// The type of the output.
type Output;
/// The type of the RTP payload to be stored in the output packet.
type Payload: PayloadLength;
/// The type of the RTP extension data to be stored in the output packet:was.
type Extension: PayloadLength;

/// Reserve a number of bytes in the output. Multiple calls are possible and provide the
Expand Down Expand Up @@ -445,6 +450,7 @@ pub struct RtpPacketWriterMutSlice<'a, 'b, 'c> {
}

impl<'a, 'b, 'c> RtpPacketWriterMutSlice<'a, 'b, 'c> {
/// Construct a new [`RtpPacketWriterMutSlice`] from the provided slice.
pub fn new(buf: &'a mut [u8]) -> Self {
Self {
output: buf,
Expand Down Expand Up @@ -520,6 +526,7 @@ pub struct RtpPacketWriterMutVec<'a, 'b, 'c> {
}

impl<'a, 'b, 'c> RtpPacketWriterMutVec<'a, 'b, 'c> {
/// Construct a new [`RtpPacketWriterMutVec`] from a provided mutable `Vec<u8>`.
pub fn new(buf: &'a mut Vec<u8>) -> Self {
Self {
output: buf,
Expand Down
8 changes: 8 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
// SPDX-License-Identifier: MIT OR Apache-2.0

#![deny(missing_debug_implementations)]
#![deny(missing_docs)]

//! # rtp-types
//!
//! An implementation of parsing, writing, and editing RTP packets as specified in [RFC 3550]
//!
//! [RFC 3550]: https://tools.ietf.org/html/rfc3550
mod builder;
mod edit;
Expand All @@ -13,6 +20,7 @@ pub use builder::{
pub use edit::RtpPacketMut;
pub use packet::{RtpPacket, RtpParseError};

/// Prelude module for defined/implementable traits
pub mod prelude {
pub use crate::builder::{PayloadLength, RtpPacketWriter};
}

0 comments on commit 699d482

Please sign in to comment.