github.com/filecoin-project/go-state-types@v0.13.0/abi/cbor_bytes_transparent.go (about) 1 package abi 2 3 import ( 4 "io" 5 ) 6 7 // CborBytesTransparent NOTE This struct does not create a valid cbor-encoded byte slice. It just passes the bytes through as-is. 8 type CborBytesTransparent []byte 9 10 // MarshalCBOR Does NOT marshall to a cbor-encoding. This is just syntactic sugar to let us pass bytes transparently through lotus which requires a cbor-marshallable object. 11 func (t *CborBytesTransparent) MarshalCBOR(w io.Writer) error { 12 _, err := w.Write(*t) 13 return err 14 } 15 16 // UnmarshalCBOR CANNOT read a cbor-encoded byte slice. This will just transparently pass the underlying bytes. 17 // This method is also risky, as it reads unboundedly. Do NOT use it for anything vulnerable. 18 func (t *CborBytesTransparent) UnmarshalCBOR(r io.Reader) error { 19 var err error 20 *t, err = io.ReadAll(r) 21 return err 22 }