code: func (s *RawSerializer) Encode(obj runtime.Object, w io.Writer) error {
  	switch t := obj.(type) {
  	case bufferedMarshaller:
  		// this path performs a single allocation during write but requires the caller to implement
  		// the more efficient Size and MarshalTo methods
  		encodedSize := uint64(t.Size())
  		data := make([]byte, encodedSize)
  
  		n, err := t.MarshalTo(data)
  		if err != nil {
  			return err
  		}
  		_, err = w.Write(data[:n])
  		return err
  
  	case proto.Marshaler:
  		// this path performs extra allocations
  		data, err := t.Marshal()
  		if err != nil {
  			return err
  		}
  		_, err = w.Write(data)
  		return err
  
  	default:
  		return errNotMarshalable{reflect.TypeOf(obj)}
  	}
  }
docs: // Encode serializes the provided object to the given writer. Overrides is ignored.