View Source ExDicom.SharedCopy (EX_DICOM v0.1.0)

Module containing helper functions for working with binary data in DICOM parsing.

Summary

Functions

Creates a binary slice of the input binary data.

Functions

copy(binary, byte_offset, length)

@spec copy(binary(), non_neg_integer(), non_neg_integer()) ::
  {:ok, binary()} | {:error, String.t()}

Creates a binary slice of the input binary data.

Parameters

  • binary - The input binary data
  • byte_offset - Offset into the binary to start the slice
  • length - Number of bytes to include in the slice

Returns

  • {:ok, binary} - A binary slice sharing the same underlying memory
  • {:error, String.t()} - Error message if the input is invalid

Examples

iex> DicomParser.copy(<<1, 2, 3, 4>>, 1, 2)
{:ok, <<2, 3>>}