FileBasedIdStorage class final
An IdStorage persisted as one JSON file, loaded on first use.
Codes are written sorted so the file diffs cleanly, and every mutation is written through before it reports success — a store that only mutated memory would look correct for a session and lose everything after it.
- Implemented types
Constructors
- FileBasedIdStorage({required File file})
-
Creates a store backed by
file; the file is created on first write.
Properties
Methods
-
add(
{required String idType, required String idCode}) → Future< Either< IdStorageFailure, Unit> > -
Records
idCodeunderidType, keeping whatever is already stored.override -
clear(
) → Future< Either< IdStorageFailure, Unit> > -
Drops every code and every counter.
override
-
codesFor(
{required String idType}) → Future< Either< IdStorageFailure, Set< >String> > -
Every code stored under
idType.override -
contains(
{required String idType, required String idCode}) → Future< Either< IdStorageFailure, bool> > -
Whether
idCodeis stored underidType.override -
counterFor(
{required String idType}) → Future< Either< IdStorageFailure, int> > -
The counter stored for
idType, or 0 when none was ever set.override -
idTypes(
) → Future< Either< IdStorageFailure, Set< >String> > -
Every id type holding at least one code.
override
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
remove(
{required String idType, required String idCode}) → Future< Either< IdStorageFailure, Unit> > -
Removes
idCodefromidType; removing an absent code is a success.override -
setCounter(
{required String idType, required int value}) → Future< Either< IdStorageFailure, Unit> > -
Stores
valueas the counter foridType.override -
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited