Timestamp.fromRaw constructor

Timestamp.fromRaw(
  1. Uint8List raw
)

Wraps a raw 24-byte z_timestamp_t image.

Timestamps originate from Session.newTimestamp() or from a received sample; constructing one directly is not the intended route.

⚠️ Nothing prevents it. This constructor is ordinary public API — it carries no annotation, and naming it from a consumer draws no diagnostic at all. (Corrected: this said the constructor was "reachable only within the package", which was measured FALSE. Dart has no package-private modifier, and a dartdoc that claims a fence which is not there is worse than one that claims nothing.)

It is safe in the way the rest of this class is: the 24-byte invariant below is enforced by a real throw, and the bytes are copied defensively, so an image of the wrong length is refused.

Implementation

Timestamp.fromRaw(Uint8List raw)
  // The 24-byte invariant is enforced by a real throw, not an `assert`:
  // asserts are stripped in release builds, where a wrong-length image
  // would otherwise be accepted silently. Canon's `z_timestamp_t` is a
  // fixed 24 bytes, so no other length is expressible.
  : _raw = _checkedCopy(raw);