code: func (o *Options) UnmarshalBinary(p []byte) error {
  	buf := buffer.New(p)
  	*o = make(Options)
  
  	for buf.Len() >= 4 {
  		// 2 bytes: option code
  		// 2 bytes: option length n
  		// n bytes: data
  		code := OptionCode(buf.Read16())
  		length := buf.Read16()
  
  		// N bytes: option data
  		data := buf.Consume(int(length))
  		if data == nil {
  			return ErrInvalidOptions
  		}
  		data = data[:int(length):int(length)]
  
  		o.AddRaw(code, data)
  	}
  
  	// Report error for any trailing bytes
  	if buf.Len() != 0 {
  		return ErrInvalidOptions
  	}
  	return nil
  }
docs: // UnmarshalBinary fills opts with option codes and corresponding values from
  // an input byte slice.
  //
  // It is used with various different types to enable parsing of both top-level
  // options, and options embedded within other options. If options data is
  // malformed, it returns ErrInvalidOptions.