Skip to main content

hurray_file_reader_new

Function hurray_file_reader_new 

Source
#[unsafe(no_mangle)]
pub unsafe extern "C" fn hurray_file_reader_new( transport: *const HurrayTransport, out_handle: *mut *mut HurrayFileReader, ) -> HurrayStatus
Expand description

Opens a Hurray file over transport: header, trailer, footer index and KV section.

The transport’s read_at and size callbacks are both required — the container is located from its end, so its size is a precondition of opening it. The vtable is copied, so the caller MAY free the HurrayTransport struct immediately; its ctx must stay valid until the reader is destroyed, at which point the vtable’s release callback is invoked.

Returns:

  • HURRAY_OK — *out_handle is a new reader.
  • HURRAY_ERR_INVALID_MAGIC — not a HRRYFILE.
  • HURRAY_ERR_VERSION_MISMATCH — a container version this build does not read.
  • HURRAY_ERR_INVALID_FILE — the footer does not check out: a CRC mismatch, an index overrunning the trailer, unknown header flags.
  • HURRAY_ERR_UNEXPECTED_EOF — the file is shorter than its own structure claims.
  • Whatever status a callback returned, if it failed. A failed open is terminal: there is no index to start from, so create a new reader rather than retrying this one.

§Safety

  • transport MUST point to a readable HurrayTransport for the duration of the call.
  • out_handle MUST be a valid, non-null, writable pointer.