rmw-bytes 0.1.14

to bytes and from bytes
Documentation
  • Coverage
  • 0%
    0 out of 5 items documented0 out of 3 items with examples
  • Size
  • Source code size: 6.35 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 1.2 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 12s Average build duration of successful builds.
  • all releases: 12s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • Repository
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • gcxfd

rmw-bytes

to bytes and from bytes

use example

use anyhow::Result;
use rmw_bytes::Bytes;
use std::net::{Ipv4Addr, Ipv6Addr, SocketAddrV4, SocketAddrV6};

fn main() -> Result<()> {
  let x: u16 = 12345;
  let bytes = x.encode();
  dbg!(u16::decode(&bytes)?, bytes);

  let x: bool = false;
  let bytes = x.encode();
  dbg!(bool::decode(&bytes)?, bytes);

  let x = SocketAddrV6::new(
    Ipv6Addr::new(1, 2, 0xa, 0xb, 0xc, 0xd, 0xe, 0xf),
    8080,
    0,
    0,
  );
  let bytes = x.encode();
  dbg!(SocketAddrV6::decode(&bytes)?, bytes);

  let x = SocketAddrV4::new(Ipv4Addr::new(1, 2, 3, 4), 8080);
  let bytes = x.encode();
  dbg!(SocketAddrV4::decode(&bytes)?, bytes);

  Ok(())
}

output as below


关于

本项目隶属于人民网络(rmw.link) 代码计划。

人民网络