forc_crypto::args

Function read_content_filepath_or_stdin

Source
pub fn read_content_filepath_or_stdin(arg: Option<String>) -> Vec<u8> 
Expand description

Reads the arg and returns a vector of bytes

These are the rules

  1. If None, stdin is read.
  2. If it’s a String and it happens to be a file path, its content will be returned
  3. If it’s a String and it is “-”, stdin is read
  4. If the string starts with “0x”, it will be treated as a hex string. Only fully valid hex strings are accepted.
  5. Otherwise the String will be converted to a vector of bytes