save method
Persists policy to the underlying storage.
Returns Ok<void> on success or Err<StorageFailure> on failure.
Implementation
@override
Future<Result<void, DomainFailure>> save(Policy policy) async {
try {
final json = _codec.encode(policy);
await _prefs.setString(storageKey, json);
return const Ok(null);
} catch (e) {
return Err(
StorageFailure('Failed to save policies: $e', cause: e),
);
}
}