浏览代码

dhcp/wire: Rename DhcpOptionsBuffer -> DhcpOptionWriter

Dario Nieuwenhuis 2 年之前
父节点
当前提交
2566754daf
共有 2 个文件被更改,包括 7 次插入7 次删除
  1. 6 6
      src/wire/dhcpv4.rs
  2. 1 1
      src/wire/mod.rs

+ 6 - 6
src/wire/dhcpv4.rs

@@ -59,17 +59,17 @@ impl MessageType {
 /// A buffer for DHCP options.
 #[derive(Debug)]
 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
-pub struct DhcpOptionsBuffer<'a> {
+pub struct DhcpOptionWriter<'a> {
     /// The underlying buffer, directly from the DHCP packet representation.
     buffer: &'a mut [u8],
 }
 
-impl<'a> DhcpOptionsBuffer<'a> {
+impl<'a> DhcpOptionWriter<'a> {
     pub fn new(buffer: &'a mut [u8]) -> Self {
         Self { buffer }
     }
 
-    /// Emit a  [`DhcpOption`] into a [`DhcpOptionsBuffer`].
+    /// Emit a  [`DhcpOption`] into a [`DhcpOptionWriter`].
     pub fn emit(&mut self, option: DhcpOption<'_>) -> Result<()> {
         if option.data.len() > u8::MAX as _ {
             return Err(Error);
@@ -533,8 +533,8 @@ impl<T: AsRef<[u8]> + AsMut<[u8]>> Packet<T> {
 impl<'a, T: AsRef<[u8]> + AsMut<[u8]> + ?Sized> Packet<&'a mut T> {
     /// Return a pointer to the options.
     #[inline]
-    pub fn options_mut(&mut self) -> DhcpOptionsBuffer<'_> {
-        DhcpOptionsBuffer::new(&mut self.buffer.as_mut()[field::OPTIONS])
+    pub fn options_mut(&mut self) -> DhcpOptionWriter<'_> {
+        DhcpOptionWriter::new(&mut self.buffer.as_mut()[field::OPTIONS])
     }
 }
 
@@ -1243,7 +1243,7 @@ mod test {
         };
 
         let mut bytes = vec![0xa5; 5];
-        let mut writer = DhcpOptionsBuffer::new(&mut bytes);
+        let mut writer = DhcpOptionWriter::new(&mut bytes);
         writer.emit(dhcp_option).unwrap();
 
         assert_eq!(

+ 1 - 1
src/wire/mod.rs

@@ -243,7 +243,7 @@ pub use self::tcp::{
 
 #[cfg(feature = "proto-dhcpv4")]
 pub use self::dhcpv4::{
-    DhcpOption, DhcpOptionsBuffer, MessageType as DhcpMessageType, Packet as DhcpPacket,
+    DhcpOption, DhcpOptionWriter, MessageType as DhcpMessageType, Packet as DhcpPacket,
     Repr as DhcpRepr, CLIENT_PORT as DHCP_CLIENT_PORT,
     MAX_DNS_SERVER_COUNT as DHCP_MAX_DNS_SERVER_COUNT, SERVER_PORT as DHCP_SERVER_PORT,
 };