// IsBadPointerKeyError indicates that the parsed data has an invalid key.
761409
func IsBadPointerKeyError(err error) bool {
	if e, ok := err.(interface {
		BadPointerKeyError() bool
	}); ok {
		return e.BadPointerKeyError()
	}

	if parent := parentOf(err); parent != nil {
		return IsBadPointerKeyError(parent)
	}
	return false
}
642338
func (sc *Client) HasKeyPair(ctx context.Context, id string) (bool, error) {
	var has bool
	return has, sc.c.CallContext(ctx, &has, "shh_hasKeyPair", id)
}
529950
func ErrIfKeyExists(err error) error {
	if err == nil || strings.Contains(err.Error(), "key not found") {
		return nil
	}

	return err
}
1235797
func decodeDBPointer(rd *bufio.Reader) (string, DBPointer, error) {
	// name
	name, err := readCstring(rd)
	if err != nil {
		return "", DBPointer{}, err
	}

	// value
	Name, err := readString(rd)
	if err != nil {
		return "", DBPointer{}, err
	}
	b := make([]byte, 12)
	_, err = io.ReadFull(rd, b)
	if err != nil {
		return "", DBPointer{}, err
	}
	return name, DBPointer{Name: Name, ObjectId: ObjectId(b)}, nil
}
364718
func isInternalDSError(err error) bool {
	if err == nil {
		return false
	}

	merr, _ := err.(errors.MultiError)
	if merr == nil {
		return true // an overall RPC error
	}

	for _, e := range merr {
		if e != nil && e != datastore.ErrNoSuchEntity {
			return true // some serious issues with this single entity
		}
	}

	return false // all suberrors are either nil or ErrNoSuchEntity
}
496292
func (s Slice) searchObjectKeyBinary(attribute string, ieBase ValueLength, n ValueLength, offsetSize ValueLength) (Slice, error) {
	useTranslator := attributeTranslator != nil
	vpackAssert(n > 0)

	l := ValueLength(0)
	r := ValueLength(n - 1)
	index := ValueLength(r / 2)

	for {
		offset := ValueLength(ieBase + index*offsetSize)
		key := Slice(s[readIntegerFixed(s[offset:], uint(offsetSize)):])

		var res int
		var err error
		if key.IsString() {
			res, err = key.CompareString(attribute)
			if err != nil {
				return nil, WithStack(err)
			}
		} else if key.IsSmallInt() || key.IsUInt() {
			// translate key
			if !useTranslator {
				// no attribute translator
				return nil, WithStack(NeedAttributeTranslatorError)
			}
			res, err = key.translateUnchecked().CompareString(attribute)
			if err != nil {
				return nil, WithStack(err)
			}
		} else {
			// invalid key
			return nil, nil
		}

		if res == 0 {
			// found. now return a Slice pointing at the value
			keySize, err := key.ByteSize()
			if err != nil {
				return nil, WithStack(err)
			}
			return Slice(key[keySize:]), nil
		}

		if res > 0 {
			if index == 0 {
				return nil, nil
			}
			r = index - 1
		} else {
			l = index + 1
		}
		if r < l {
			return nil, nil
		}

		// determine new midpoint
		index = l + ((r - l) / 2)
	}
}
610110
func (e KeyHalfMismatchError) Error() string {
	return fmt.Sprintf("Key mismatch, expected ID: %s, actual ID: %s",
		e.Expected, e.Actual)
}
1150490
func (key *Key) GetPubKeyBlob() (pubkey []byte, err error) {
	var dataLen C.UINT32
	var cData *C.BYTE
	err = tspiError(C.Tspi_GetAttribData((C.TSS_HOBJECT)(key.handle), C.TSS_TSPATTRIB_KEY_BLOB, C.TSS_TSPATTRIB_KEYBLOB_PUBLIC_KEY, &dataLen, &cData))
	data := C.GoBytes(unsafe.Pointer(cData), (C.int)(dataLen))
	C.Tspi_Context_FreeMemory(key.context, cData)
	return data, err
}
564598
func IsAdbServerErrorMatching(err error, predicate func(string) bool) bool {
	if err, ok := err.(*errors.Err); ok && err.Code == errors.AdbError {
		return predicate(err.Details.(ErrorResponseDetails).ServerMsg)
	}
	return false
}
484722
func IsBadRequestError(err error) bool {
	return yarpcerrors.FromError(err).Code() == yarpcerrors.CodeInvalidArgument
}
373425
func IsForeignKeyViolation(err error, indexName string) bool {
	if err == nil {
		return false
	}
	pqError, ok := err.(*pq.Error)
	if !ok {
		return false
	}
	return pqError.Code == errForeignKeyViolation && pqError.Constraint == indexName
}
54092
func isNoSuchNameError(err error) bool {
	_, ok := err.(idutil.NoSuchNameError)
	return ok
}
329220
func annotateBinary(span *zipkincore.Span, key string, value interface{}, host *zipkincore.Endpoint) {
	if b, ok := value.(bool); ok {
		if b {
			value = "true"
		} else {
			value = "false"
		}
	}
	span.BinaryAnnotations = append(span.BinaryAnnotations, &zipkincore.BinaryAnnotation{
		Key:            key,
		Value:          []byte(fmt.Sprintf("%+v", value)),
		AnnotationType: zipkincore.AnnotationType_STRING,
		Host:           host,
	})
}
329469
func IsBroadcastError(err error, codes ...BroadcastErrorCode) bool {
	broadcastErr, ok := err.(*BroadcastError)
	if !ok {
		return false
	}

	for _, code := range codes {
		if broadcastErr.Code == code {
			return true
		}
	}

	return false
}
1093352
func IsAuthenticationError(err error) bool {
	cause := errors.Cause(err)
	if kvErr, ok := cause.(KeyValueError); ok && kvErr.KVError() {
		return kvErr.StatusCode() == int(gocbcore.StatusAuthError)
	}

	return false
}
347935
func ValidateEndpointGroup(obj *EndpointGroup) error {
	collections.endpointGroupMutex.Lock()
	defer collections.endpointGroupMutex.Unlock()

	// Validate key is correct
	keyStr := obj.TenantName + ":" + obj.GroupName
	if obj.Key != keyStr {
		log.Errorf("Expecting EndpointGroup Key: %s. Got: %s", keyStr, obj.Key)
		return errors.New("Invalid Key")
	}

	// Validate each field

	if len(obj.CfgdTag) > 128 {
		return errors.New("cfgdTag string too long")
	}

	cfgdTagMatch := regexp.MustCompile("^((([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\\-]*[a-zA-Z0-9])\\.)*([A-Za-z0-9]|[A-Za-z0-9][A-Za-z0-9\\-]*[A-Za-z0-9]))?$")
	if cfgdTagMatch.MatchString(obj.CfgdTag) == false {
		return errors.New("cfgdTag string invalid format")
	}

	if len(obj.GroupName) > 64 {
		return errors.New("groupName string too long")
	}

	groupNameMatch := regexp.MustCompile("^(([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\\-]*[a-zA-Z0-9])\\.)*([A-Za-z0-9]|[A-Za-z0-9][A-Za-z0-9\\-]*[A-Za-z0-9])$")
	if groupNameMatch.MatchString(obj.GroupName) == false {
		return errors.New("groupName string invalid format")
	}

	ipPoolMatch := regexp.MustCompile("^$|^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])(\\.(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])){3})(\\-((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])(\\.(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])){3}))?$")
	if ipPoolMatch.MatchString(obj.IpPool) == false {
		return errors.New("ipPool string invalid format")
	}

	if len(obj.NetProfile) > 64 {
		return errors.New("netProfile string too long")
	}

	if len(obj.NetworkName) > 64 {
		return errors.New("networkName string too long")
	}

	networkNameMatch := regexp.MustCompile("^(([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\\-]*[a-zA-Z0-9])\\.)*([A-Za-z0-9]|[A-Za-z0-9][A-Za-z0-9\\-]*[A-Za-z0-9])$")
	if networkNameMatch.MatchString(obj.NetworkName) == false {
		return errors.New("networkName string invalid format")
	}

	if len(obj.TenantName) > 64 {
		return errors.New("tenantName string too long")
	}

	tenantNameMatch := regexp.MustCompile("^(([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\\-]*[a-zA-Z0-9])\\.)*([A-Za-z0-9]|[A-Za-z0-9][A-Za-z0-9\\-]*[A-Za-z0-9])$")
	if tenantNameMatch.MatchString(obj.TenantName) == false {
		return errors.New("tenantName string invalid format")
	}

	return nil
}
82794
func (o *Option) IsKey(key string) bool {
	return strings.ToLower(o.Key) == strings.ToLower(key)
}