@@ -158,6 +158,49 @@ impl Packets {
158158 byte_count_to_read
159159 }
160160
161+ /// Returns the number of packets
162+ ///
163+ /// # Examples
164+ ///
165+ /// ```rust
166+ /// use ogg_pager::Packets;
167+ ///
168+ /// # fn main() -> Result<(), ogg_pager::PageError> {
169+ /// # let path = "../tests/files/assets/minimal/full_test.ogg";
170+ /// let mut file = std::fs::File::open(path)?;
171+ ///
172+ /// // I want to read 2 packets
173+ /// let packets = Packets::read_count(&mut file, 2)?;
174+ ///
175+ /// // And that's what I received!
176+ /// assert_eq!(packets.len(), 2);
177+ /// # Ok(()) }
178+ /// ```
179+ pub fn len ( & self ) -> usize {
180+ self . packet_sizes . len ( )
181+ }
182+
183+ /// Returns true if there are no packets
184+ ///
185+ /// # Examples
186+ ///
187+ /// ```rust
188+ /// use ogg_pager::Packets;
189+ ///
190+ /// # fn main() -> Result<(), ogg_pager::PageError> {
191+ /// # let path = "../tests/files/assets/minimal/full_test.ogg";
192+ /// let mut file = std::fs::File::open(path)?;
193+ ///
194+ /// let packets = Packets::read(&mut file)?;
195+ ///
196+ /// // My file contains packets!
197+ /// assert_eq!(!packets.is_empty());
198+ /// # Ok(()) }
199+ /// ```
200+ pub fn is_empty ( & self ) -> bool {
201+ self . packet_sizes . is_empty ( )
202+ }
203+
161204 /// Gets the packet at a specified index, returning its contents
162205 ///
163206 /// NOTES:
0 commit comments