blob: 584d7777ced9d91b624ce54ab1fb1486e2931a48 [file] [log] [blame]
// Copyright 2019 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package fidl
import (
"syscall/zx/internal/context"
)
type Context = context.Context
type marshalerContextKey struct{}
// GetMarshalerContext returns the MarshalerContext stored on ctx if it exists;
// otherwise the bool return value will be false.
func GetMarshalerContext(ctx Context) (MarshalerContext, bool) {
marshalerCtx, ok := ctx.Value(marshalerContextKey{}).(MarshalerContext)
return marshalerCtx, ok
}
// WithMarshalerContext returns a Context that embeds parent and stores
// marshalerCtx.
func WithMarshalerContext(parent Context, marshalerCtx MarshalerContext) Context {
return context.WithValue(parent, marshalerContextKey{}, marshalerCtx)
}