pub struct NflverseData { /* private fields */ }Implementations§
Source§impl NflverseData
impl NflverseData
Sourcepub async fn request_refresh(&self) -> Result<bool, NflverseDataError>
pub async fn request_refresh(&self) -> Result<bool, NflverseDataError>
Request a detached refresh. Returns false if a background refresh is running. Manual requests and scheduled requests share the same runner.
pub fn refresh_status(&self) -> RefreshStatus
Sourcepub fn start_scheduler(&self, interval: Duration) -> bool
pub fn start_scheduler(&self, interval: Duration) -> bool
Start one timer per instance; the first refresh is after a full interval. Returns false if already started. Zero disables (and stops) the timer. Stop before starting again to change the interval. Construction never starts it.
Sourcepub fn stop_scheduler(&self) -> bool
pub fn stop_scheduler(&self) -> bool
Stop future timer triggers without cancelling any detached refresh in progress.
Source§impl NflverseData
impl NflverseData
Sourcepub async fn connect(
config: NflverseDataConfig,
) -> Result<Self, NflverseDataError>
pub async fn connect( config: NflverseDataConfig, ) -> Result<Self, NflverseDataError>
Opens (creating if missing) the cache database and runs migrations.
Sourcepub async fn connect_with_sync_notify(
config: NflverseDataConfig,
sync_notify: Option<UnboundedSender<()>>,
) -> Result<Self, NflverseDataError>
pub async fn connect_with_sync_notify( config: NflverseDataConfig, sync_notify: Option<UnboundedSender<()>>, ) -> Result<Self, NflverseDataError>
Self::connect, also notifying sync_notify after each fully
successful sync.
Sourcepub async fn connect_with_sync_events(
config: NflverseDataConfig,
sync_events: Option<UnboundedSender<SyncEvent>>,
) -> Result<Self, NflverseDataError>
pub async fn connect_with_sync_events( config: NflverseDataConfig, sync_events: Option<UnboundedSender<SyncEvent>>, ) -> Result<Self, NflverseDataError>
Self::connect, also sending one SyncEvent per completed sync on
sync_events.
Sourcepub async fn in_memory() -> Result<Self, NflverseDataError>
pub async fn in_memory() -> Result<Self, NflverseDataError>
A fresh, empty, in-memory cache — for tests and tooling that need an
NflverseData handle without a database file. Migrations are applied; no data
is synced.
Sourcepub async fn weekly_roster_entries_by_gsis<I: AsRef<str>>(
&self,
ids: &[I],
) -> Result<HashMap<String, WeeklyRosterEntry>, NflverseDataError>
pub async fn weekly_roster_entries_by_gsis<I: AsRef<str>>( &self, ids: &[I], ) -> Result<HashMap<String, WeeklyRosterEntry>, NflverseDataError>
Most recent weekly roster entry for each id, keyed by gsis id. Ids with no entry are absent from the map rather than an error.
Complements Self::players_by_gsis: candidate lists are built from
weekly rosters, and 144 of 2025’s 3,133 rostered players have no row in
the players table, so a pick cannot always be named from there.
Sourcepub async fn games(
&self,
season: Season,
) -> Result<Vec<Game>, NflverseDataError>
pub async fn games( &self, season: Season, ) -> Result<Vec<Game>, NflverseDataError>
All cached games for a season, ordered by week.
Sourcepub async fn players(&self) -> Result<Vec<Player>, NflverseDataError>
pub async fn players(&self) -> Result<Vec<Player>, NflverseDataError>
All cached players, ordered by name.
Sourcepub async fn players_by_gsis<I: AsRef<str>>(
&self,
ids: &[I],
) -> Result<HashMap<String, Player>, NflverseDataError>
pub async fn players_by_gsis<I: AsRef<str>>( &self, ids: &[I], ) -> Result<HashMap<String, Player>, NflverseDataError>
Players for a small set of ids, keyed by gsis id. Ids with no player are absent from the map rather than an error — callers render a fallback.
One indexed seek per id — ~25µs for a nine-slot lineup, so the loop is
not worth batching at the sizes call sites actually pass. If that ever
changes, the set-based form is WHERE gsis_id IN (SELECT value FROM json_each(?)): one bind parameter and static SQL, so query_as! still
applies and no FromRow impl is needed. It does require gsis_id to
lead an index — SQLite will not skip-scan an IN list, and drops to a
full table scan without one.
Sourcepub async fn weekly_roster(
&self,
season_week: SeasonWeek,
team: &TeamAbbr,
) -> Result<Vec<WeeklyRosterEntry>, NflverseDataError>
pub async fn weekly_roster( &self, season_week: SeasonWeek, team: &TeamAbbr, ) -> Result<Vec<WeeklyRosterEntry>, NflverseDataError>
A team’s cached roster for one week, ordered by player name.
Sourcepub async fn player_week_stats(
&self,
season_week: SeasonWeek,
) -> Result<Vec<PlayerWeekStats>, NflverseDataError>
pub async fn player_week_stats( &self, season_week: SeasonWeek, ) -> Result<Vec<PlayerWeekStats>, NflverseDataError>
All players’ cached stat lines for one week, ordered by player GSIS id.
Sourcepub async fn team_week_stats(
&self,
season_week: SeasonWeek,
) -> Result<Vec<TeamWeekStats>, NflverseDataError>
pub async fn team_week_stats( &self, season_week: SeasonWeek, ) -> Result<Vec<TeamWeekStats>, NflverseDataError>
All teams’ pbp-derived DST lines for one week (sacks, takeaways, TDs, blocks, conversion returns, and points_allowed = the opponent’s offensive points). Ordered by team.
Sourcepub async fn freshness(
&self,
) -> Result<Vec<DatasetFreshness>, NflverseDataError>
pub async fn freshness( &self, ) -> Result<Vec<DatasetFreshness>, NflverseDataError>
Freshness for every dataset, in sync order.
Sourcepub async fn sync(&self) -> Result<SyncReport, NflverseDataError>
pub async fn sync(&self) -> Result<SyncReport, NflverseDataError>
Fetch all datasets from nflverse, skipping assets whose upstream updated_at matches the cache. Failures are isolated per dataset and reported in the SyncReport; Err is reserved for setup-level failures. For per-season datasets, isolation is finer still: a bad season’s asset doesn’t block the other seasons in the same dataset from updating.
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for NflverseData
impl !UnwindSafe for NflverseData
impl Freeze for NflverseData
impl Send for NflverseData
impl Sync for NflverseData
impl Unpin for NflverseData
impl UnsafeUnpin for NflverseData
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<A, B, T> HttpServerConnExec<A, B> for Twhere
B: Body,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more