e071084ebe
govulncheck / govulncheck (push) Has been cancelled
Lint / golangci-lint (push) Has been cancelled
Run Tests / Unit Tests (push) Has been cancelled
Run Tests / Etcd Integration Tests (push) Has been cancelled
Harness (E2E) / Harnesses (mock LLM) (push) Has been cancelled
Harness (E2E) / Provider harnesses (live LLM conformance) (push) Has been cancelled
41 lines
634 B
Go
41 lines
634 B
Go
package bytes
|
|
|
|
import (
|
|
"go-micro.dev/v6/codec"
|
|
)
|
|
|
|
type Marshaler struct{}
|
|
|
|
type Message struct {
|
|
Header map[string]string
|
|
Body []byte
|
|
}
|
|
|
|
func (n Marshaler) Marshal(v interface{}) ([]byte, error) {
|
|
switch ve := v.(type) {
|
|
case *[]byte:
|
|
return *ve, nil
|
|
case []byte:
|
|
return ve, nil
|
|
case *Message:
|
|
return ve.Body, nil
|
|
}
|
|
return nil, codec.ErrInvalidMessage
|
|
}
|
|
|
|
func (n Marshaler) Unmarshal(d []byte, v interface{}) error {
|
|
switch ve := v.(type) {
|
|
case *[]byte:
|
|
*ve = d
|
|
return nil
|
|
case *Message:
|
|
ve.Body = d
|
|
return nil
|
|
}
|
|
return codec.ErrInvalidMessage
|
|
}
|
|
|
|
func (n Marshaler) String() string {
|
|
return "bytes"
|
|
}
|