rmw_str

Crates.iormw_str
lib.rsrmw_str
version0.0.7
sourcesrc
created_at2022-01-10 06:36:10.702789
updated_at2022-03-07 10:31:16.63824
descriptionto str and from str
homepage
repositoryhttps://github.com/rmw-lib/node/tree/master/str
max_upload_size
id511228
size6,522
gcxfd (gcxfd)

documentation

README

rmw-str

to str and from str

use example

use anyhow::Result;
use rmw_str::Str;
use std::net::{Ipv4Addr, Ipv6Addr, SocketAddrV4, SocketAddrV6};

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

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

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

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

  Ok(())
}

output as below


关于

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

人民网络

Commit count: 0

cargo fmt