Skip to main content

finance_query/models/corporate/news/
scraped.rs

1//! Scraped news article model.
2
3use serde::{Deserialize, Serialize};
4
5/// A news article
6#[derive(Debug, Clone, Serialize, Deserialize)]
7#[cfg_attr(feature = "dataframe", derive(crate::ToDataFrame))]
8#[non_exhaustive]
9pub struct News {
10    /// Article title
11    pub title: String,
12
13    /// Article URL
14    pub link: String,
15
16    /// News source/publisher (e.g., "Reuters", "Bloomberg")
17    pub source: String,
18
19    /// Thumbnail image URL
20    pub img: String,
21
22    /// Relative time when the news was published (e.g., "1 hour ago", "2 days ago")
23    pub time: String,
24
25    /// Which provider supplied this article (None = Yahoo Finance default)
26    pub provider_id: Option<crate::providers::Provider>,
27}
28
29impl News {
30    /// Create a new News article
31    pub(crate) fn new(
32        title: String,
33        link: String,
34        source: String,
35        img: String,
36        time: String,
37    ) -> Self {
38        Self {
39            title,
40            link,
41            source,
42            img,
43            time,
44            provider_id: None,
45        }
46    }
47}