MCPcopy
hub / github.com/ory/hydra / additionalDataFromOpts

Function additionalDataFromOpts

flow/encoding.go:58–73  ·  view source on GitHub ↗
(opts ...CodecOption)

Source from the content-addressed store, hash-verified

56)
57
58func additionalDataFromOpts(opts ...CodecOption) []byte {
59 if len(opts) == 0 {
60 return nil
61 }
62 ad := &data{}
63 for _, o := range opts {
64 o(ad)
65 }
66 b, err := json.Marshal(ad)
67 if err != nil {
68 // Panic is OK here because the struct and the parameters are all known.
69 panic("failed to marshal additional data: " + errors.WithStack(err).Error())
70 }
71
72 return b
73}
74
75// Decode decodes the given string to a value.
76func Decode[T any](ctx context.Context, cipher aead.Cipher, encoded string, opts ...CodecOption) (*T, error) {

Callers 2

DecodeFunction · 0.85
EncodeFunction · 0.85

Calls 1

ErrorMethod · 0.45

Tested by

no test coverage detected