fn dump_header(buffer: &[u8]) -> &[u8] {
    println!("== Header Information ==");

    let rest = buffer;

    // Field 1 (some sort of header)
    let length = read_u16(rest) as usize;
    let (_, rest) = read_n_byte(&rest[2..], length);

    // Field 2
    let length = read_u16(rest) as usize;
    let (_, rest) = read_n_byte(&rest[2..], length);

    // Field 3 (NCD name)
    let length = read_u16(rest) as usize;
    let (value, rest) = read_n_byte(&rest[2..], length);
    println!("NCD name          : {}", str::from_utf8(value).unwrap());

    // Field 4 (model/part number)
    let length = read_u16(&rest[1..]) as usize;
    let (value, rest) = read_n_byte(&rest[3..], length);
    println!("model/part number : {}", str::from_utf8(value).unwrap());

    // Field 5 (built date)
    let length = read_u16(&rest[1..]) as usize;
    let (value, rest) = read_n_byte(&rest[3..], length);
    println!("built date        : {}", str::from_utf8(value).unwrap());

    // Field 6 (built time)
    let length = read_u16(&rest[1..]) as usize;
    let (value, rest) = read_n_byte(&rest[3..], length);
    println!("built time        : {}", str::from_utf8(value).unwrap());

    // Field 7 (data length)
    let length = read_u32(&rest[1..]) as usize;
    let rest = &rest[5..];
    println!("data length       : 0x{:08x}", length);

    rest
}
/*
 * For the format of the header information, see implementation of the file command.
 * https://github.com/file/file/blob/master/magic/Magdir/xilinx
 */
For the format of the header information, see implementation of the file command.
For the format of the header information see implementation of the file command .
fn dump_header(buffer: &[u8]) -> &[u8] {
    println!("== Header Information ==");
    let rest = buffer;
    // Field 1 (some sort of header)
    let length = read_u16(rest) as usize;
    let (_, rest) = read_n_byte(&rest[2..], length);
    // Field 2
    let length = read_u16(rest) as usize;
    let (_, rest) = read_n_byte(&rest[2..], length);
    // Field 3 (NCD name)
    let length = read_u16(rest) as usize;
    let (value, rest) = read_n_byte(&rest[2..], length);
    println!("NCD name          : {}", str::from_utf8(value).unwrap());
    // Field 4 (model/part number)
    let length = read_u16(&rest[1..]) as usize;
    let (value, rest) = read_n_byte(&rest[3..], length);
    println!("model/part number : {}", str::from_utf8(value).unwrap());
    // Field 5 (built date)
    let length = read_u16(&rest[1..]) as usize;
    let (value, rest) = read_n_byte(&rest[3..], length);
    println!("built date        : {}", str::from_utf8(value).unwrap());
    // Field 6 (built time)
    let length = read_u16(&rest[1..]) as usize;
    let (value, rest) = read_n_byte(&rest[3..], length);
    println!("built time        : {}", str::from_utf8(value).unwrap());
    // Field 7 (data length)
    let length = read_u32(&rest[1..]) as usize;
    let rest = &rest[5..];
    println!("data length       : 0x{:08x}", length);
    rest
}
fn dump_header ( buffer : & [ u8 ] ) -> & [ u8 ] { println ! ( " " ) ; let rest = buffer ; // Field 1 (some sort of header) let length = read_u16 ( rest ) as usize ; let ( _ , rest ) = read_n_byte ( & rest [ 2 .. ] , length ) ; // Field 2 let length = read_u16 ( rest ) as usize ; let ( _ , rest ) = read_n_byte ( & rest [ 2 .. ] , length ) ; // Field 3 (NCD name) let length = read_u16 ( rest ) as usize ; let ( value , rest ) = read_n_byte ( & rest [ 2 .. ] , length ) ; println ! ( " " str from_utf8 ( value ) unwrap ( ) ) ; // Field 4 (model/part number) let length = read_u16 ( & rest [ 1 .. ] ) as usize ; let ( value , rest ) = read_n_byte ( & rest [ 3 .. ] , length ) ; println ! ( " " str from_utf8 ( value ) unwrap ( ) ) ; // Field 5 (built date) let length = read_u16 ( & rest [ 1 .. ] ) as usize ; let ( value , rest ) = read_n_byte ( & rest [ 3 .. ] , length ) ; println ! ( " " str from_utf8 ( value ) unwrap ( ) ) ; // Field 6 (built time) let length = read_u16 ( & rest [ 1 .. ] ) as usize ; let ( value , rest ) = read_n_byte ( & rest [ 3 .. ] , length ) ; println ! ( " " str from_utf8 ( value ) unwrap ( ) ) ; // Field 7 (data length) let length = read_u32 ( & rest [ 1 .. ] ) as usize ; let rest = & rest [ 5 .. ] ; println ! ( " " length ) ; rest }
For the format of the header information, see implementation of the file command.
For the format of the header information see implementation of the file command .
buffer
&[u8]
buffer
&[u8]