MCPcopy Create free account
hub / github.com/SeaQL/FireDBG.for.Rust / from_str

Method from_str

protocol/src/value.rs:900–914  ·  view source on GitHub ↗
(s: &str)

Source from the content-addressed store, hash-verified

898 type Err = &'static str;
899
900 fn from_str(s: &str) -> std::result::Result<Self, Self::Err> {
901 let mut addr = [0u8; 8];
902 let bytes = s.as_bytes();
903 if bytes.len() != 18 {
904 return Err("Not 8 bytes?");
905 }
906 let mut i = 2;
907 while i < 18 {
908 let str = std::str::from_utf8(&bytes[i..i + 2]).unwrap();
909 let b = u8::from_str_radix(str, 16).map_err(|_| "Invalid byte")?;
910 addr[7 - (i - 2) / 2] = b;
911 i += 2;
912 }
913 Ok(Addr(addr))
914 }
915}
916
917impl Display for RefAddr {

Callers

nothing calls this directly

Calls 4

AddrClass · 0.85
as_bytesMethod · 0.80
parseMethod · 0.80
lenMethod · 0.45

Tested by

no test coverage detected