length method

  1. @override
Future<ResourceTry<int>> length()

Returns data length from metadata if available, or calculated from reading the bytes otherwise.

This value must be treated as a hint, as it might not reflect the actual bytes length. To get the real length, you need to read the whole resource.


Future<ResourceTry<int>> length() async {
  int? length = await _metadataLength();
  if (length != null) {
    return ResourceTry.success(length);
  return read()
      .then((data) => data.mapCatching((value) => value.lengthInBytes));