pub struct SessionState {
pub blz: Blz,
pub user_id: UserId,
pub system_id: SystemId,
pub bpd_version: u16,
pub upd_version: u16,
pub tan_method: Option<SecurityFunction>,
pub tan_medium: Option<TanMediumName>,
pub allowed_security_functions: Vec<SecurityFunction>,
pub previous_user_id: Option<UserId>,
pub tan_required_learned: Vec<SegmentType>,
pub updated_at: Timestamp,
/* private fields */
}Expand description
What one user’s dialogs with one bank leave behind for the next run.
Store the state that Dialog::end or jobs::synchronise returns after
every dialog and pass it to the next jobs::open. With it, the next
dialog skips the sync dialog, announces the cached BPD/UPD versions so
the bank sends nothing it has already sent, and keeps the system ID the
bank knows. A lost state gets a new system ID, and a bank that granted
an SCA exemption (3076) to the old one may ask for a login TAN again.
Debug hides user ID, system ID and the UPD content.
Fields§
§blz: BlzThe bank code.
user_id: UserIdThe login. When the bank announces a new one (return code 3072) it replaces the old one here.
system_id: SystemIdThe customer system ID from HISYN; 0 until the bank gave one.
bpd_version: u16The BPD version HKVVB announces; 0 asks for the BPD.
upd_version: u16The UPD version HKVVB announces; 0 asks for the UPD.
tan_method: Option<SecurityFunction>The security function (TAN method) the user prefers, such as 902.
tan_medium: Option<TanMediumName>The TAN medium (device) to name for methods that need one.
allowed_security_functions: Vec<SecurityFunction>The security functions of the bank’s last return code 3920.
previous_user_id: Option<UserId>The login used before the bank’s last 3072, so the caller can update
what it stores; user_id already holds the new one.
tan_required_learned: Vec<SegmentType>Order codes (e.g. HKSAL) for which the bank answered 9075 without
HKTAN; the library sends HKTAN with them at once. Dropped by reset.
updated_at: TimestampWhen the state was written.
Implementations§
Source§impl SessionState
impl SessionState
Sourcepub fn new(blz: &Blz, user_id: &UserId) -> Self
pub fn new(blz: &Blz, user_id: &UserId) -> Self
The state before the first dialog: nothing known.
Sourcepub fn with_system_id(self, system_id: &SystemId) -> Self
pub fn with_system_id(self, system_id: &SystemId) -> Self
Start from a known system ID. The host stores the ID itself, so a state format change keeps the bank’s device entry: the new state has no BPD or UPD (one parameter dialog fetches them) but no new sync dialog either.
Sourcepub fn with_tan_method(self, security_function: &SecurityFunction) -> Self
pub fn with_tan_method(self, security_function: &SecurityFunction) -> Self
Ask for this security function whenever the bank offers it.
Sourcepub fn with_tan_medium(self, medium: &TanMediumName) -> Self
pub fn with_tan_medium(self, medium: &TanMediumName) -> Self
Name this device to methods that ask for a TAN medium.
Sourcepub fn can_skip_sync(&self) -> bool
pub fn can_skip_sync(&self) -> bool
Whether the next dialog can go straight to business: the bank gave a system ID and the BPD (with the TAN methods) is cached.
Sourcepub fn tan_methods(&self) -> Vec<TanMethod>
pub fn tan_methods(&self) -> Vec<TanMethod>
The TAN methods of the cached BPD.
Sourcepub fn capabilities(&self, accounts: &[Account]) -> Capabilities
pub fn capabilities(&self, accounts: &[Account]) -> Capabilities
What the bank offers per account (accounts, or the cached UPD’s
accounts when empty), from the cached BPD and UPD and the learned
TAN codes; sends nothing. Without a stored UPD (none yet, or a bank
that sends it for one dialog only, see SessionState::upd) pass
the accounts; every UPD allowance is then Unknown, and
Dialog::capabilities knows the
dialog’s UPD. TAN overrides of the client config are not applied here.
Sourcepub fn accounts(&self, bank_bic: &Bic) -> Vec<AccountInfo>
pub fn accounts(&self, bank_bic: &Bic) -> Vec<AccountInfo>
Accounts listed in the cached UPD (none when the bank sends the UPD
for one dialog only, see SessionState::upd), as
Opened::accounts lists them;
bank_bic fills in the BIC the UPD does not give.
Sourcepub fn reset(&mut self)
pub fn reset(&mut self)
Forget everything the bank sent, for instance when it no longer accepts the system ID (9391); the next run synchronises again. Bank, login and the user’s TAN choice stay.
Sourcepub fn from_json(json: &str) -> Result<Self>
pub fn from_json(json: &str) -> Result<Self>
Deserialize from JSON produced by SessionState::to_json. Any
other format tag, older or newer, fails with
FinTSError::StateFormat; there is no migration.