Skip to main content

nurtex_protocol/types/
property.rs

1use nurtex_codec::Buffer;
2
3#[derive(Clone, Debug, PartialEq)]
4pub struct Property {
5  pub name: String,
6  pub value: String,
7  pub signature: Option<String>,
8}
9
10impl Buffer for Property {
11  fn read_buf(buffer: &mut std::io::Cursor<&[u8]>) -> Option<Self> {
12    Some(Self {
13      name: String::read_buf(buffer)?,
14      value: String::read_buf(buffer)?,
15      signature: Option::read_buf(buffer)?,
16    })
17  }
18
19  fn write_buf(&self, buffer: &mut impl std::io::Write) -> std::io::Result<()> {
20    self.name.write_buf(buffer)?;
21    self.value.write_buf(buffer)?;
22    self.signature.write_buf(buffer)?;
23    Ok(())
24  }
25}