Skip to main content

NflverseData

Struct NflverseData 

Source
pub struct NflverseData { /* private fields */ }

Implementations§

Source§

impl NflverseData

Source

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.

Source

pub fn refresh_status(&self) -> RefreshStatus

Source

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.

Source

pub fn stop_scheduler(&self) -> bool

Stop future timer triggers without cancelling any detached refresh in progress.

Source§

impl NflverseData

Source

pub async fn connect( config: NflverseDataConfig, ) -> Result<Self, NflverseDataError>

Opens (creating if missing) the cache database and runs migrations.

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub async fn games( &self, season: Season, ) -> Result<Vec<Game>, NflverseDataError>

All cached games for a season, ordered by week.

Source

pub async fn players(&self) -> Result<Vec<Player>, NflverseDataError>

All cached players, ordered by name.

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub async fn freshness( &self, ) -> Result<Vec<DatasetFreshness>, NflverseDataError>

Freshness for every dataset, in sync order.

Source

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§

Source§

impl Clone for NflverseData

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<A, B, T> HttpServerConnExec<A, B> for T
where B: Body,

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts 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
§

impl<T> PolicyExt for T
where T: ?Sized,

§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] only if self and other return Action::Follow. Read more
§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more