| 44 | var errStackDepthExceeded = errors.DefineResourceExhausted("stack_depth_exceeded", "stack depth exceeded") |
| 45 | |
| 46 | func createSerializationState(opts ...Option) (*serializationState, error) { |
| 47 | serializationState := &serializationState{ |
| 48 | depth: 1, |
| 49 | } |
| 50 | for _, opt := range opts { |
| 51 | opt(serializationState) |
| 52 | } |
| 53 | if serializationState.depth > maxNestingDepth { |
| 54 | return nil, errStackDepthExceeded.New() |
| 55 | } |
| 56 | return serializationState, nil |
| 57 | } |
| 58 | |
| 59 | // Map returns the Struct proto as a map[string]interface{}. |
| 60 | func Map(p *structpb.Struct, opts ...Option) (map[string]any, error) { |