falco_event/types/net/
ipv6net.rs1use crate::fields::{FromBytes, FromBytesError, ToBytes};
2use std::fmt::{Debug, Formatter};
3use std::io::Write;
4use std::net::Ipv6Addr;
5
6#[derive(Copy, Clone, PartialEq, Eq)]
11pub struct Ipv6Net(pub Ipv6Addr);
12
13impl FromBytes<'_> for Ipv6Net {
14 #[inline]
15 fn from_bytes(buf: &mut &[u8]) -> Result<Self, FromBytesError> {
16 Ok(Self(Ipv6Addr::from_bytes(buf)?))
17 }
18}
19
20impl ToBytes for Ipv6Net {
21 #[inline]
22 fn binary_size(&self) -> usize {
23 self.0.binary_size()
24 }
25
26 #[inline]
27 fn write<W: Write>(&self, writer: W) -> std::io::Result<()> {
28 self.0.write(writer)
29 }
30
31 #[inline]
32 fn default_repr() -> impl ToBytes {
33 Ipv6Addr::default_repr()
34 }
35}
36
37impl Debug for Ipv6Net {
38 fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
39 Debug::fmt(&self.0, f)
40 }
41}