anchor.diff:              ?TYPE_VARINT -> decode_varint(Content);
               ?TYPE_STRING ->
                   {Length, R1} = decode_varint(Content),
  -                {Value, R2} = split_binary(R1, Length),
  +                {Value, R2} = my_split_binary(R1, Length),
                   {{'block', Value}, R2};
               ?TYPE_64BIT ->
  -                split_binary(Content, 8);
  +                my_split_binary(Content, 8);
               ?TYPE_32BIT ->
  -                split_binary(Content, 4)
  +                my_split_binary(Content, 4)
           end,
       {{FieldCode, FieldValue}, Rest}.
  +
  +
  +my_split_binary(X, Pos) when byte_size(X) >= Pos ->
  +    split_binary(X, Pos);
  +my_split_binary(_X, _Pos) ->
  +    error('not_enough_data').
  +
  +
  +-spec parse_field_part/1 :: (
  +    Bytes :: binary() ) -> 'undefined' | {parsed_field(), Rest :: binary()}.
  +
  +% Similar to parse_field/1, but if there's not enough data, 'undefined' is
  +% returned as the result.
  +parse_field_part(Bytes) ->
  +    try
  +        parse_field(Bytes)
  +    catch
  +        % raised in either parse_field_header/1 or in parse_field/1 meaning that
  +        % there's not enough data
  +        {'piqirun_error', 'not_enough_data'} -> 'undefined'
  +    end.
   
   
   -spec parse_record/1 :: (
  
positive.code:     find_fields(Code, T, Accu, [H | Rest]).
  
  
  parse_binobj(Binobj) ->
      L = parse_record_buf(Binobj),
      case L of
          [{2, X}] -> % anonymous binobj
              {'undefined', X};
          [{1, Nameobj}, {2, X}] -> % named binobj
              % strings are encoded as variable-length blocks
              Name = string_of_block(Nameobj),
              {Name, X}
      end.
  
  
  parse_default(X) ->
    {_, Res} = parse_binobj(X),
    Res.
  
  
  -spec error/1 :: (any()) -> no_return().
  
negative.code:             end, 0, Acc1),
      {Result, Rest};
  decode_varint(<<1:1, I:7, Rest/binary>>, Acc) ->
      decode_varint(Rest, [I | Acc]);
  decode_varint(Bytes, _Acc) when is_binary(Bytes) ->
      % Return the same error as returned by my_split_binary/2 when parsing
      % fields (see below). This way, when there's not enough data for parsing a
      % field, the returned error is the same regardless of where it occured.
      error('not_enough_data').
  
  
  -spec gen_record/2 :: (
  