• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

jzombie / rust-sec-fetcher / 23224625495

18 Mar 2026 01:26AM UTC coverage: 37.013%. First build
23224625495

push

github

web-flow
Refactor caching, examples, and bins (#34)

273 of 900 new or added lines in 37 files covered. (30.33%)

1244 of 3361 relevant lines covered (37.01%)

1707.77 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/src/models/filing_document.rs
1
/// Represents a single document entry within an SEC EDGAR filing index.
2
///
3
/// Parsed from the EDGAR HTML filing index page (`{accession}-index.htm`).
4
///
5
/// # Common `document_type` values
6
///
7
/// | Type pattern | Description |
8
/// |---|---|
9
/// | `"8-K"`, `"10-K"`, `"10-Q"` | Primary form body |
10
/// | `"EX-99.1"`, `"EX-99.2"` | Press release / earnings release |
11
/// | `"EX-10.1"` … `"EX-10.x"` | Material contracts |
12
/// | `"EX-21.1"` | Subsidiaries of the registrant |
13
/// | `"EX-23.1"` | Auditor / accountant consent |
14
/// | `"EX-31.1"`, `"EX-31.2"` | SOX § 302 certifications (CEO/CFO) |
15
/// | `"EX-32.1"`, `"EX-32.2"` | SOX § 906 certifications (CEO/CFO) |
16
/// | `"EX-101.INS"` … `"EX-101.PRE"` | XBRL instance / schema / label files |
17
/// | `"GRAPHIC"` | Image files (logos, charts) |
18
/// | `"XML"`, `""` | Ancillary machine-readable files |
19
#[derive(Debug, Clone)]
20
pub struct FilingDocument {
21
    /// File name within the filing archive (e.g. `"ex991.htm"`).
22
    pub name: String,
23

24
    /// SEC document type string (e.g. `"EX-99.1"`, `"8-K"`).
25
    pub document_type: String,
26
}
27

28
impl FilingDocument {
29
    /// Returns `true` if this document is an exhibit (type starts with `"EX-"`).
30
    pub fn is_exhibit(&self) -> bool {
×
31
        self.document_type.to_uppercase().starts_with("EX-")
×
32
    }
×
33

34
    /// Returns `true` if this is a press release or earnings release exhibit.
35
    ///
36
    /// Matches `EX-99.x` — the standard type used for press releases,
37
    /// earnings tables, and Regulation FD voluntary disclosures.
NEW
38
    pub fn is_press_release(&self) -> bool {
×
NEW
39
        let t = self.document_type.to_uppercase();
×
NEW
40
        t.starts_with("EX-99")
×
NEW
41
    }
×
42

43
    /// Returns `true` if this is a Sarbanes-Oxley certification exhibit.
44
    ///
45
    /// Matches `EX-31.x` (§ 302 CEO/CFO certifications) and `EX-32.x`
46
    /// (§ 906 certifications).  These are short, formulaic legal documents
47
    /// with no analytical content.
NEW
48
    pub fn is_sarbanes_oxley_cert(&self) -> bool {
×
NEW
49
        let t = self.document_type.to_uppercase();
×
NEW
50
        t.starts_with("EX-31") || t.starts_with("EX-32")
×
NEW
51
    }
×
52

53
    /// Returns `true` if this is an auditor or accountant consent exhibit (`EX-23.x`).
54
    ///
55
    /// Consent forms are short single-page documents required when financial
56
    /// statements are incorporated by reference; they contain no analytical
57
    /// content.
NEW
58
    pub fn is_auditor_consent(&self) -> bool {
×
NEW
59
        self.document_type.to_uppercase().starts_with("EX-23")
×
NEW
60
    }
×
61

62
    /// Returns `true` if this is an XBRL structured data exhibit (`EX-101.*`).
63
    ///
64
    /// These are machine-readable schema, instance, label, and calculation
65
    /// documents that duplicate the financial data already present in the
66
    /// primary HTML document.  They contain no human-readable prose.
NEW
67
    pub fn is_xbrl_data(&self) -> bool {
×
NEW
68
        self.document_type.to_uppercase().starts_with("EX-101")
×
NEW
69
    }
×
70

71
    /// Returns `true` if this exhibit contains substantive, human-readable content.
72
    ///
73
    /// An exhibit is substantive if it:
74
    /// - Is an `EX-*` document, **and**
75
    /// - Is **not** a SOX certification (`EX-31.x`, `EX-32.x`)
76
    /// - Is **not** an auditor consent (`EX-23.x`)
77
    /// - Is **not** an XBRL data file (`EX-101.*`)
78
    /// - Is **not** a raw graphic (`GRAPHIC`)
79
    ///
80
    /// Substantive exhibits include press releases (`EX-99.x`), material
81
    /// contracts (`EX-10.x`), subsidiary lists (`EX-21.x`), and any other
82
    /// exhibit that contains actual prose or financial tables.
83
    ///
84
    /// Use [`FilingIndex::substantive_exhibits`] to filter a filing's documents
85
    /// to only those worth rendering or embedding.
NEW
86
    pub fn is_substantive_exhibit(&self) -> bool {
×
NEW
87
        if !self.is_exhibit() {
×
NEW
88
            return false;
×
NEW
89
        }
×
NEW
90
        if self.is_sarbanes_oxley_cert() || self.is_auditor_consent() || self.is_xbrl_data() {
×
NEW
91
            return false;
×
NEW
92
        }
×
NEW
93
        if self.document_type.to_uppercase() == "GRAPHIC" {
×
NEW
94
            return false;
×
NEW
95
        }
×
NEW
96
        true
×
NEW
97
    }
×
98

99
    /// Returns `true` if the file is an HTML document.
100
    pub fn is_html(&self) -> bool {
×
101
        let n = self.name.to_lowercase();
×
102
        n.ends_with(".htm") || n.ends_with(".html")
×
103
    }
×
104

105
    /// Returns `true` if the file is a plain-text document.
106
    pub fn is_text(&self) -> bool {
×
107
        self.name.to_lowercase().ends_with(".txt")
×
108
    }
×
109
}
110

111
/// The full document listing for a single SEC EDGAR filing.
112
///
113
/// Fetch via [`crate::network::fetch_filing_index`].
114
#[derive(Debug)]
115
pub struct FilingIndex {
116
    /// All documents listed in this filing archive.
117
    pub documents: Vec<FilingDocument>,
118
}
119

120
impl FilingIndex {
121
    /// Returns all exhibit documents from this filing (any `EX-*` type).
122
    ///
123
    /// Includes everything: press releases, SOX certs, auditor consents,
124
    /// XBRL data files, and graphics.  Use [`Self::substantive_exhibits`]
125
    /// to filter to only human-readable content.
126
    pub fn exhibits(&self) -> Vec<&FilingDocument> {
×
127
        self.documents
×
128
            .iter()
×
129
            .filter(|doc| doc.is_exhibit())
×
130
            .collect()
×
131
    }
×
132

133
    /// Returns only the substantive exhibits — those containing human-readable
134
    /// prose or financial tables.
135
    ///
136
    /// Excludes SOX certifications, auditor consents, XBRL data files, and
137
    /// graphics.  This is the right default filter when rendering or embedding
138
    /// a filing's attachments.
139
    ///
140
    /// See [`FilingDocument::is_substantive_exhibit`] for the exact criteria.
NEW
141
    pub fn substantive_exhibits(&self) -> Vec<&FilingDocument> {
×
NEW
142
        self.documents
×
NEW
143
            .iter()
×
NEW
144
            .filter(|doc| doc.is_substantive_exhibit())
×
NEW
145
            .collect()
×
NEW
146
    }
×
147

148
    /// Returns only press release exhibits (`EX-99.x`).
149
    ///
150
    /// These are typically earnings announcements, Regulation FD voluntary
151
    /// disclosures, and other company-authored statements attached to 8-K
152
    /// filings.  To find earnings releases specifically, check the parent
153
    /// [`CikSubmission::is_earnings_release`] before fetching the index.
154
    ///
155
    /// [`CikSubmission::is_earnings_release`]: crate::models::CikSubmission::is_earnings_release
NEW
156
    pub fn press_releases(&self) -> Vec<&FilingDocument> {
×
NEW
157
        self.documents
×
NEW
158
            .iter()
×
NEW
159
            .filter(|doc| doc.is_press_release())
×
NEW
160
            .collect()
×
NEW
161
    }
×
162
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc