// Inject implements Injector of BinaryPropagator
966777
func (p *BinaryPropagator) Inject(
	sc SpanContext,
	abstractCarrier interface{},
) error {
	carrier, ok := abstractCarrier.(io.Writer)
	if !ok {
		return opentracing.ErrInvalidCarrier
	}

	// Handle the tracer context
	if err := binary.Write(carrier, binary.BigEndian, sc.traceID); err != nil {
		return err
	}
	if err := binary.Write(carrier, binary.BigEndian, sc.spanID); err != nil {
		return err
	}
	if err := binary.Write(carrier, binary.BigEndian, sc.parentID); err != nil {
		return err
	}
	if err := binary.Write(carrier, binary.BigEndian, sc.flags); err != nil {
		return err
	}

	// Handle the baggage items
	if err := binary.Write(carrier, binary.BigEndian, int32(len(sc.baggage))); err != nil {
		return err
	}
	for k, v := range sc.baggage {
		if err := binary.Write(carrier, binary.BigEndian, int32(len(k))); err != nil {
			return err
		}
		io.WriteString(carrier, k)
		if err := binary.Write(carrier, binary.BigEndian, int32(len(v))); err != nil {
			return err
		}
		io.WriteString(carrier, v)
	}

	return nil
}
701175
func (ds *DataScope) Injector(tagname string) app.Injector {
	return injector.NewMapInjector(tagname, ds.Data)
}
1308165
func (fn _bindFunctionObject) construct(argumentList []Value) Value {
	object := fn.target
	switch value := object.value.(type) {
	case _nativeFunctionObject:
		return value.construct(object, fn.argumentList)
	case _nodeFunctionObject:
		argumentList = append(fn.argumentList, argumentList...)
		return object.construct(argumentList)
	}
	panic(fn.target.runtime.panicTypeError())
}
227252
func InjectRequestHeaders(r *http.Request) {
	if span := GetSpan(r); span != nil {
		err := opentracing.GlobalTracer().Inject(
			span.Context(),
			opentracing.HTTPHeaders,
			HTTPHeadersCarrier(r.Header))
		if err != nil {
			log.FromContext(r.Context()).Error(err)
		}
	}
}
1207356
func (mi MapInjector) InjectTo(obj interface{}) error {
	structValue := reflect.ValueOf(obj).Elem()
	for i := 0; i < structValue.NumField(); i++ {
		var isRequired = true
		valueField := structValue.Field(i)
		structField := structValue.Type().Field(i)
		key := structField.Tag.Get(mi.tagname)
		if key == "" {
			continue
		}
		if strings.HasPrefix(key, "?") {
			isRequired = false
			key = key[1:]
		}
		if !valueField.IsValid() {
			return fmt.Errorf("MapInjector.InjectTo: %s is not valid", structField.Name)
		}
		if !valueField.CanSet() {
			return fmt.Errorf("MapInjector.InjectTo: Cannot set %s field value", structField.Name)
		}
		newValue, ok := mi.data[key]
		if !ok {
			if !isRequired {
				continue
			}
			return fmt.Errorf("value for %s is unknown", key)
		}
		if newValue == nil {
			return fmt.Errorf("MapInjector.InjectTo: dependency instance can not be nil (%s)", key)
		}
		refValue := reflect.ValueOf(newValue)
		valueField.Set(refValue)
	}
	return nil
}
1201264
func (s *StructInjector) InjectElem(destElem reflect.Value, ctx ...reflect.Value) {
	for _, f := range s.fields {
		f.Object.Assign(ctx, func(v reflect.Value) {
			destElem.FieldByIndex(f.FieldIndex).Set(v)
		})
	}
}
805948
func (hc *quorumhttpclient) injectDefault(cmd interface{}, out interface{}) bool {
	// use defaults for non quorum results
	if hc.settings.Defaults == nil {
		return false
	}
	switch x := cmd.(type) {
	case *WereAddressesSpentFromCommand:
		if hc.settings.Defaults.WereAddressesSpentFrom != nil {
			states := make([]bool, len(x.Addresses))
			for i := range states {
				states[i] = *hc.settings.Defaults.WereAddressesSpentFrom
			}
			out.(*WereAddressesSpentFromResponse).States = states
			return true
		}
	case *GetInclusionStatesCommand:
		if hc.settings.Defaults.GetInclusionStates != nil {
			states := make([]bool, len(x.Transactions))
			for i := range states {
				states[i] = *hc.settings.Defaults.GetInclusionStates
			}
			out.(*GetInclusionStatesResponse).States = states
			return true
		}
	case *GetBalancesCommand:
		if hc.settings.Defaults.GetBalances != nil {
			balances := make([]string, len(x.Addresses))
			for i := range balances {
				balances[i] = strconv.Itoa(int(*hc.settings.Defaults.GetBalances))
			}
			out.(*GetBalancesResponse).Balances = balances
			return true
		}
	}
	return false
}
596460
func (inj *injector) Apply(val interface{}) error {
	v := reflect.ValueOf(val)

	for v.Kind() == reflect.Ptr {
		v = v.Elem()
	}

	if v.Kind() != reflect.Struct {
		return nil // Should not panic here ?
	}

	t := v.Type()

	for i := 0; i < v.NumField(); i++ {
		f := v.Field(i)
		structField := t.Field(i)
		if f.CanSet() && (structField.Tag == "inject" || structField.Tag.Get("inject") != "") {
			ft := f.Type()
			v := inj.GetVal(ft)
			if !v.IsValid() {
				return fmt.Errorf("Value not found for type %v", ft)
			}

			f.Set(v)
		}

	}

	return nil
}
1083662
func (mi MultiInjector) InjectTo(obj interface{}) error {
	for _, injector := range mi.injectors {
		if err := injector.InjectTo(obj); err != nil {
			return err
		}
	}
	return nil
}
1239319
func (f *AllFilter) ConstructPBFilter() (*pb.Filter, error) {
	return &pb.Filter{
		Name:             proto.String(filterPath + "FilterAllFilter"),
		SerializedFilter: pb.MustMarshal(&pb.FilterAllFilter{}),
	}, nil
}
451857
func InjectHTTP(r *http.Request) propagation.Injector {
	return func(sc model.SpanContext) error {
		if (model.SpanContext{}) == sc {
			return ErrEmptyContext
		}

		if sc.Debug {
			r.Header.Set(Flags, "1")
		} else if sc.Sampled != nil {
			// Debug is encoded as X-B3-Flags: 1. Since Debug implies Sampled,
			// so don't also send "X-B3-Sampled: 1".
			if *sc.Sampled {
				r.Header.Set(Sampled, "1")
			} else {
				r.Header.Set(Sampled, "0")
			}
		}

		if !sc.TraceID.Empty() && sc.ID > 0 {
			r.Header.Set(TraceID, sc.TraceID.String())
			r.Header.Set(SpanID, sc.ID.String())
			if sc.ParentID != nil {
				r.Header.Set(ParentSpanID, sc.ParentID.String())
			}
		}

		return nil
	}
}
1134514
func (c *Context) BindBuffer(target int, buffer *js.Object) {
	c.Call("bindBuffer", target, buffer)
}
581407
func (b *BiMap) Insert(k interface{}, v interface{}) {
	b.s.RLock()
	if b.immutable {
		panic("Cannot modify immutable map")
	}
	b.s.RUnlock()

	b.s.Lock()
	defer b.s.Unlock()
	b.forward[k] = v
	b.inverse[v] = k
}
236743
func NewInjector(name string) *Injector {
	var failPercent, _ = strconv.Atoi(os.Getenv("FAULT_" + strings.ToUpper(name) + "_FAIL_PERCENT"))
	return &Injector{
		failPercent: failPercent,
	}
}
1077756
func InjectTrace(r *http.Request) {
	if span := opentracing.SpanFromContext(r.Context()); span != nil {
		span.Tracer().Inject(
			span.Context(),
			opentracing.HTTPHeaders,
			opentracing.HTTPHeadersCarrier(r.Header),
		)
	}
}
44980
func (pl *Payload) WriteBinary(w io.Writer) error {
	enc := gob.NewEncoder(w)
	return pl.EncodeBinary(enc)
}
1180252
func Injector(parent inject.Injector) gin.HandlerFunc {
	return func(c *gin.Context) {
		inj := inject.New()
		inj.SetParent(parent)
		inj.Map(inj)
		inj.Map(c)

		c.Set(metaInjectorKey, inj)

		c.Next()
	}
}