// GetLength determines the length of the Header.
439555
func (h *ExtendedHeader) GetLength(v protocol.VersionNumber) protocol.ByteCount {
	if h.IsLongHeader {
		length := 1 /* type byte */ + 4 /* version */ + 1 /* conn id len byte */ + protocol.ByteCount(h.DestConnectionID.Len()+h.SrcConnectionID.Len()) + protocol.ByteCount(h.PacketNumberLen) + utils.VarIntLen(uint64(h.Length))
		if h.Type == protocol.PacketTypeInitial {
			length += utils.VarIntLen(uint64(len(h.Token))) + protocol.ByteCount(len(h.Token))
		}
		return length
	}

	length := protocol.ByteCount(1 /* type byte */ + h.DestConnectionID.Len())
	length += protocol.ByteCount(h.PacketNumberLen)
	return length
}
1248168
func RandomLength(length int, lang string) (string, error) {
	return RandomLengthDelim(length, " ", lang)
}
1302218
func StringLength(str string) (strlen int) {
	str = vtclean.Clean(str, false)
	for str != "" {
		_, rest, runeWidth := ReadRune(str)
		str = rest
		strlen += runeWidth
	}
	// Alternative:
	// strlen = utf8.RuneCountInString(str)
	// Alternative:
	// var ia norm.Iter
	// ia.InitString(norm.NFKD, str)
	return
}
723743
func (o *FuzzyCompletionSuggesterOptions) PrefixLength(prefixLength int) *FuzzyCompletionSuggesterOptions {
	o.prefixLength = &prefixLength
	return o
}
643805
func MaxLength(length int) Validator {
	// return a validator that checks the length of the string
	return func(val interface{}) error {
		if str, ok := val.(string); ok {
			// if the string is longer than the given value
			if len([]rune(str)) > length {
				// yell loudly
				return fmt.Errorf("value is too long. Max length is %v", length)
			}
		} else {
			// otherwise we cannot convert the value into a string and cannot enforce length
			return fmt.Errorf("cannot enforce length on response of type %v", reflect.TypeOf(val).Name())
		}

		// the input is fine
		return nil
	}
}
506855
func (h Header) Get(key string) interface{} {
	if h == nil {
		return nil
	}
	return h[key]
}
569598
func (d *CompoundFileDirectory) FileLength(name string) (n int64, err error) {
	panic("not implemented yet")
}
234751
func getlength(bs *BlockDriverState) (int64, error) {
	length, err := nbSectors(bs)
	if err != nil {
		return 0, err
	}

	if length > int64(INT64_MAX/BDRV_SECTOR_SIZE) {
		return 0, syscall.EFBIG
	}
	return length * int64(BDRV_SECTOR_SIZE), nil
}
419956
func (q *MatchQuery) PrefixLength(length int) *MatchQuery {
	q.options["prefix_length"] = length
	return q
}
747892
func (m *Match) matchLength(cap int) int {
	i := m.matches[cap][m.matchcount[cap]*2-1]
	if i >= 0 {
		return i
	}

	return m.matches[cap][-3-i]
}
1291541
func ContentLength(length int64) PutObjectInput {
	return func(req *s3.PutObjectInput) {
		req.ContentLength = aws.Int64(length)
	}
}
488527
func ToLength(i []byte, rpl byte, length int) []byte {
	if len(i) == length {
		return i
	} else if len(i) > length {
		return i[:length]
	} else {
		var o = make([]byte, length)
		o = i
		for idx := 0; idx < length-len(i); idx++ {
			o = append(o, rpl)
		}
		return o
	}
}
347896
func unrefPrefixLength(prefixLengths map[int]int, length int) {
	value, _ := prefixLengths[length]
	if value <= 1 {
		delete(prefixLengths, length)
	} else {
		prefixLengths[length]--
	}
}
542046
func (v *Validator) MaxLength(field string, length int) *ValidationResult {
	val := v.data.Get(field)
	trimmed := strings.TrimSpace(val)
	if len(trimmed) > length {
		return v.addMaxLengthError(field, length)
	} else {
		return validationOk
	}
}
506248
func (sc *StringConstraint) MinLength(l int) *StringConstraint {
	sc.minLength = l
	return sc
}
939024
func (f *FileAsset) GetLength() int {
	file, err := os.Open(f.AssetName)
	defer file.Close()
	if err != nil {
		return 0
	}
	fi, err := file.Stat()
	if err != nil {
		return 0
	}
	return int(fi.Size())
}
1296128
func (f *StopSendingFrame) Length(_ protocol.VersionNumber) protocol.ByteCount {
	return 1 + utils.VarIntLen(uint64(f.StreamID)) + 2
}