MCPcopy Create free account
hub / github.com/Dstack-TEE/dstack / cmd_hex

Function cmd_hex

dstack-util/src/main.rs:305–325  ·  view source on GitHub ↗
(hex_args: HexCommand)

Source from the content-addressed store, hash-verified

303}
304
305fn cmd_hex(hex_args: HexCommand) -> Result<()> {
306 fn hex_encode_io(io: &mut impl Read) -> Result<()> {
307 loop {
308 let mut buf = [0; 1024];
309 let n = io.read(&mut buf).context("Failed to read from stdin")?;
310 if n == 0 {
311 break;
312 }
313 print!("{}", hex_fmt::HexFmt(&buf[..n]));
314 }
315 Ok(())
316 }
317 if let Some(filename) = hex_args.filename {
318 let mut input =
319 fs::File::open(&filename).context(format!("Failed to open {}", filename))?;
320 hex_encode_io(&mut input)?;
321 } else {
322 hex_encode_io(&mut io::stdin())?;
323 };
324 Ok(())
325}
326
327fn cmd_gen_ra_cert(args: GenRaCertArgs) -> Result<()> {
328 let ca_cert = fs::read_to_string(args.ca_cert)?;

Callers 1

mainFunction · 0.85

Calls 1

hex_encode_ioFunction · 0.85

Tested by

no test coverage detected