//Runs in raw mode, with options extract from CliArgs
Runs in raw mode, with options extract from CliArgs
Runs in raw mode with options extract from CliArgs
fn run_raw(fname: Option<PathBuf>) -> io::Result<()> {
    let mut buffer: Vec<u8> = Vec::new();
    let num_bytes = match fname {
        None => io::stdin().read_to_end(&mut buffer)?,
        Some(fname) => {
            ensure_file_exists(&fname)?;
            File::open(fname)?.read_to_end(&mut buffer)?
        }
    };
    if num_bytes >= PrincipalId::MAX_LENGTH_IN_BYTES {
        return Err(io::Error::new(
            io::ErrorKind::InvalidInput,
            "Read too many bytes. PrincipalId's are bounded.",
        ));
    }
    let mut arr: [u8; PrincipalId::MAX_LENGTH_IN_BYTES] = Default::default();
    arr.copy_from_slice(&buffer[0..PrincipalId::MAX_LENGTH_IN_BYTES]);
    let pid = PrincipalId::new(num_bytes, arr);
    println!("{:?}", pid);
    Ok(())
}
fn run_raw ( fname : Option < PathBuf > ) -> io :: Result < ( ) > { let mut buffer : Vec < u8 > = Vec :: new ( ) ; let num_bytes = match fname { None => io :: stdin ( ) . read_to_end ( & mut buffer ) ? , Some ( fname ) => { ensure_file_exists ( & fname ) ? ; File :: open ( fname ) ? . read_to_end ( & mut buffer ) ? } } ; if num_bytes >= PrincipalId :: MAX_LENGTH_IN_BYTES { return Err ( io :: Error :: new ( io :: ErrorKind :: InvalidInput , " " , ) ) ; } let mut arr : [ u8 ; PrincipalId :: MAX_LENGTH_IN_BYTES ] = Default :: default ( ) ; arr . copy_from_slice ( & buffer [ 0 .. PrincipalId :: MAX_LENGTH_IN_BYTES ] ) ; let pid = PrincipalId :: new ( num_bytes , arr ) ; println ! ( " " pid ) ; Ok ( ( ) ) }
Runs in raw mode, with options extract from CliArgs
Runs in raw mode with options extract from CliArgs
fname
Option<PathBuf>