Encode Deprecated: Encoded connections are no longer supported.
(subject string, v any)
| 40 | // |
| 41 | // Deprecated: Encoded connections are no longer supported. |
| 42 | func (je *DefaultEncoder) Encode(subject string, v any) ([]byte, error) { |
| 43 | switch arg := v.(type) { |
| 44 | case string: |
| 45 | bytes := *(*[]byte)(unsafe.Pointer(&arg)) |
| 46 | return bytes, nil |
| 47 | case []byte: |
| 48 | return arg, nil |
| 49 | case bool: |
| 50 | if arg { |
| 51 | return trueB, nil |
| 52 | } else { |
| 53 | return falseB, nil |
| 54 | } |
| 55 | case nil: |
| 56 | return nilB, nil |
| 57 | default: |
| 58 | var buf bytes.Buffer |
| 59 | fmt.Fprintf(&buf, "%+v", arg) |
| 60 | return buf.Bytes(), nil |
| 61 | } |
| 62 | } |
| 63 | |
| 64 | // Decode |
| 65 | // |