1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
//! Minimal Crate for reading and manipulating `NITF` files
//! Interface for NITF version 2.1
//!
//! Constructing a [Nitf] object parses the file header and segment metadata.
//! Each segment in contains a `header` field which stores the respective
//! metadata defined in the file standard. The primary function for constructing a
//! [Nitf] is [Nitf::from_reader()]
//! ```no_run
//! // Read a nitf file and dump metadata to stdout
//! let mut nitf_file = std::fs::File::open("example.nitf").unwrap();
//! let nitf = nitf_rs::Nitf::from_reader(&mut nitf_file).unwrap();
//! println!("{nitf}");
//! ```
//!
//!
//! Aside from the `nitf_header`, all other segments use a generic [NitfSegment]
//! to provide metadata and access to the segment data.
//! ```no_run
//! // Get the bytes from the first image segment
//! let mut nitf_file = std::fs::File::open("example.nitf").unwrap();
//! let nitf = nitf_rs::Nitf::from_reader(&mut nitf_file).unwrap();
//! let im_seg = &nitf.image_segments[0];
//! let im_seg_hdr = &im_seg.header;
//! let im_seg_data = &im_seg.get_data_map(&mut nitf_file).unwrap();
//! ```
//!
//! Most metadata elements are stored in a [NitfField](types::NitfField) structure.
//! This structure has a `val` which holds on to native value of the field
//! (i.e., the bytes parsed into a u8, u16, String, enum, etc.), as well as the
//! length (in bytes) and name of the field.
//! ```no_run
//! let mut nitf_file = std::fs::File::open("example.nitf").unwrap();
//! let nitf = nitf_rs::Nitf::from_reader(&mut nitf_file).unwrap();
//! let file_title = nitf.nitf_header.ftitle.val;
//! let n_img_segments = nitf.nitf_header.numi.val;
//! let n_rows = nitf.image_segments[0].header.nrows.val;
//! ```
//!
//! If there is user-defined tagged-record-extension (TRE) data within a segment,
//! it is stored in an [ExtendedSubheader] for the user to parse accordingly.
use Error;
pub use *;
pub type NitfResult<T> = ;
// Crate specific errors