subcutaneous/dependency.rs
1use crate::Storage;
2
3/// A dependency that may get injected in an [`Applicant`][crate::Applicant].
4pub trait Dependency: Sized {
5 type Storage: Storage;
6 type State: Send + Sync;
7 type Injected<'storage, 'state>: Dependency<State = Self::State>;
8
9 fn initialize_state(storage: &mut Self::Storage) -> Self::State;
10
11 fn fetch<'storage, 'state>(
12 state: &'state mut Self::State,
13 storage: &'storage Self::Storage,
14 ) -> Self::Injected<'storage, 'state>;
15
16 fn tear_down(_state: &mut Self::State, _storage: &mut Self::Storage) {}
17}