Skip to main content

SessionState

Struct SessionState 

Source
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: Blz

The bank code.

§user_id: UserId

The login. When the bank announces a new one (return code 3072) it replaces the old one here.

§system_id: SystemId

The customer system ID from HISYN; 0 until the bank gave one.

§bpd_version: u16

The BPD version HKVVB announces; 0 asks for the BPD.

§upd_version: u16

The 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: Timestamp

When the state was written.

Implementations§

Source§

impl SessionState

Source

pub fn new(blz: &Blz, user_id: &UserId) -> Self

The state before the first dialog: nothing known.

Source

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.

Source

pub fn with_tan_method(self, security_function: &SecurityFunction) -> Self

Ask for this security function whenever the bank offers it.

Source

pub fn with_tan_medium(self, medium: &TanMediumName) -> Self

Name this device to methods that ask for a TAN medium.

Source

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.

Source

pub fn tan_methods(&self) -> Vec<TanMethod>

The TAN methods of the cached BPD.

Source

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.

Source

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.

Source

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.

Source

pub fn to_json(&self) -> Result<String>

The state as JSON, for the caller to store.

Source

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.

Trait Implementations§

Source§

impl Clone for SessionState

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

impl Debug for SessionState

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for SessionState

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Serialize for SessionState

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. 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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

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

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

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> PolicyExt for T
where T: ?Sized,

Source§

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

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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

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

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

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