cbor_enhanced 0.1.1

Cbor de/serialization library making use of lifetimes to support zero copy deserialization. Several iana tags are supported but need to be activated via feature flags.
Documentation
use std::net::IpAddr;

use crate::ser::Serializer;
use crate::types::IanaTag;
use crate::Serialize;

impl Serializer {
    pub fn write_ip_address(&mut self, address: &IpAddr) {
        self.write_tag(IanaTag::NetworkAddress);
        match address {
            IpAddr::V4(v4) => self.write_bytes(&v4.octets()),
            IpAddr::V6(v6) => self.write_bytes(&v6.octets()),
        }
    }
    pub fn write_ip_address_and_mask(&mut self, address: &IpAddr, mask: u8) {
        self.write_tag(IanaTag::NetworkAddressPlusMask);
        self.write_map_def(1);
        match address {
            IpAddr::V4(v4) => self.write_bytes(&v4.octets()),
            IpAddr::V6(v6) => self.write_bytes(&v6.octets()),
        }
        self.write_u64(mask as u64);
    }
}

impl Serialize for IpAddr {
    fn serialize(&self, serializer: &mut Serializer) {
        serializer.write_ip_address(self);
    }
}