// isPinnedWithType is the implementation of IsPinnedWithType that does not lock.
// intended for use by other pinned methods that already take locks
338257
func (p *pinner) isPinnedWithType(c cid.Cid, mode Mode) (string, bool, error) {
	switch mode {
	case Any, Direct, Indirect, Recursive, Internal:
	default:
		err := fmt.Errorf("invalid Pin Mode '%d', must be one of {%d, %d, %d, %d, %d}",
			mode, Direct, Indirect, Recursive, Internal, Any)
		return "", false, err
	}
	if (mode == Recursive || mode == Any) && p.recursePin.Has(c) {
		return linkRecursive, true, nil
	}
	if mode == Recursive {
		return "", false, nil
	}

	if (mode == Direct || mode == Any) && p.directPin.Has(c) {
		return linkDirect, true, nil
	}
	if mode == Direct {
		return "", false, nil
	}

	if (mode == Internal || mode == Any) && p.isInternalPin(c) {
		return linkInternal, true, nil
	}
	if mode == Internal {
		return "", false, nil
	}

	// Default is Indirect
	visitedSet := cid.NewSet()
	for _, rc := range p.recursePin.Keys() {
		has, err := hasChild(p.dserv, rc, c, visitedSet.Visit)
		if err != nil {
			return "", false, err
		}
		if has {
			return rc.String(), true, nil
		}
	}
	return "", false, nil
}
108288
func IsIntType(k reflect.Kind) (size int, okay bool) {
	switch k {
	case reflect.Int:
		return binary.MaxVarintLen64, true
	case reflect.Int8:
		return 2, true
	case reflect.Int16:
		return binary.MaxVarintLen16, true
	case reflect.Int32:
		return binary.MaxVarintLen32, true
	case reflect.Int64:
		return binary.MaxVarintLen64, true
	default:
		return 0, false
	}
}
612179
func (g *Generated) WithType(slicePtr interface{}) bool {
	found := false
	v, err := conversion.EnforcePtr(slicePtr)
	if err != nil || v.Kind() != reflect.Slice {
		// This should not happen at runtime.
		panic("need ptr to slice")
	}
	t := v.Type().Elem()
	for i := range g.Items {
		obj := reflect.ValueOf(g.Items[i]).Elem()
		if !obj.Type().ConvertibleTo(t) {
			continue
		}
		found = true
		v.Set(reflect.Append(v, obj.Convert(t)))
	}
	return found
}
24511
func (builder *StoreBucketTypePropsCommandBuilder) WithBucketType(bucketType string) *StoreBucketTypePropsCommandBuilder {
	builder.protobuf.Type = []byte(bucketType)
	return builder
}
871892
func GetPinWithMode(cname string, mode PinIOMode) (pin Pin, e error) {
	p, e := GetPin(cname)
	if e != nil {
		return
	}

	e = PinMode(p, mode)
	return p, e
}
158066
func IsValidType(objType ObjectType) bool {
	switch objType {
	case EndpointObject:
		fallthrough
	case NetworkObject:
		fallthrough
	case OpaqueObject:
		return true
	}
	return false
}
1197264
func type_(thread *Thread, _ *Builtin, args Tuple, kwargs []Tuple) (Value, error) {
	if len(kwargs) > 0 {
		return nil, fmt.Errorf("type does not accept keyword arguments")
	}
	if len(args) != 1 {
		return nil, fmt.Errorf("type: got %d arguments, want exactly 1", len(args))
	}
	return String(args[0].Type()), nil
}
640103
func (t SigchainV2Type) IsSupportedTeamType() bool {
	switch t {
	case SigchainV2TypeTeamRoot,
		SigchainV2TypeTeamNewSubteam,
		SigchainV2TypeTeamChangeMembership,
		SigchainV2TypeTeamRotateKey,
		SigchainV2TypeTeamLeave,
		SigchainV2TypeTeamSubteamHead,
		SigchainV2TypeTeamRenameSubteam,
		SigchainV2TypeTeamInvite,
		SigchainV2TypeTeamRenameUpPointer,
		SigchainV2TypeTeamDeleteRoot,
		SigchainV2TypeTeamDeleteSubteam,
		SigchainV2TypeTeamDeleteUpPointer,
		SigchainV2TypeTeamKBFSSettings,
		SigchainV2TypeTeamSettings:
		return true
	default:
		return false
	}
}
408132
func (t *TypeInfo) StructType() (*StructTypeInfo, error) {
	structType, ok := interface{}(t.TypeSpec.Type).(*ast.StructType)
	if !ok {
		return nil, ErrNotStructType
	}

	return (*StructTypeInfo)(structType), nil
}
989135
func underlyingPtrType(val interface{}) (interface{}, bool) {
	refVal := reflect.ValueOf(val)

	switch refVal.Kind() {
	case reflect.Ptr:
		if refVal.IsNil() {
			return nil, false
		}
		convVal := refVal.Elem().Interface()
		return convVal, true
	}

	return nil, false
}
849236
func (c *cipdSubcommand) doneWithPinMap(pins map[string][]pinInfo, err error) int {
	if len(pins) == 0 {
		if err == nil { // this error will be printed in c.done(...)
			fmt.Println("No packages.")
		}
	} else {
		printPinsAndError(pins)
	}
	if ret := c.done(pins, err); ret != 0 {
		return ret
	}
	for _, infos := range pins {
		if hasErrors(infos) {
			return 1
		}
	}
	return 0
}
781514
func (bi *BinaryInfo) Type(offset dwarf.Offset) (godwarf.Type, error) {
	return godwarf.ReadType(bi.dwarf, offset, bi.typeCache)
}
897599
func (c *Adaptor) DigitalPin(pin string, dir string) (sysfsPin sysfs.DigitalPinner, err error) {
	c.mutex.Lock()
	defer c.mutex.Unlock()

	i, err := c.translatePin(pin)

	if err != nil {
		return
	}

	if c.digitalPins[i] == nil {
		c.digitalPins[i] = sysfs.NewDigitalPin(i)
		if err = c.digitalPins[i].Export(); err != nil {
			return
		}
	}

	if err = c.digitalPins[i].Direction(dir); err != nil {
		return
	}

	return c.digitalPins[i], nil
}
530618
func (b *IOPinDriver) ReadAllPinData() (pins []PinData) {
	c, _ := b.adaptor().ReadCharacteristic(pinDataCharacteristic)
	buf := bytes.NewBuffer(c)
	pinsData := make([]PinData, buf.Len()/2)

	for i := 0; i < buf.Len()/2; i++ {
		pinData := PinData{}
		pinData.pin, _ = buf.ReadByte()
		pinData.value, _ = buf.ReadByte()
		pinsData[i] = pinData
	}

	return pinsData
}
205833
func IsType(expected interface{}, actual interface{}) bool {
	return IsEqual(reflect.TypeOf(expected), reflect.TypeOf(actual))
}
1112917
func (s *FunctionConfiguration) SetPinned(v bool) *FunctionConfiguration {
	s.Pinned = &v
	return s
}
1100513
func IndirectType(v interface{}) reflect.Type {
	typ := reflect.TypeOf(v)
	if typ.Kind() == reflect.Ptr {
		return typ.Elem()
	}

	return typ
}