// AppendUUIDFit appends a BLE advertised service UUID
// packet field if it fits in the packet, and reports whether the UUID fit.
760628
func (a *AdvPacket) AppendUUIDFit(uu []UUID) bool {
	// Iterate all UUIDs to see if they fit in the packet or not.
	fit, l := true, len(a.b)
	for _, u := range uu {
		if u.Equal(attrGAPUUID) || u.Equal(attrGATTUUID) {
			continue
		}
		l += 2 + u.Len()
		if l > MaxEIRPacketLength {
			fit = false
			break
		}
	}

	// Append the UUIDs until they no longer fit.
	for _, u := range uu {
		if u.Equal(attrGAPUUID) || u.Equal(attrGATTUUID) {
			continue
		}
		if len(a.b)+2+u.Len() > MaxEIRPacketLength {
			break
		}
		switch l = u.Len(); {
		case l == 2 && fit:
			a.AppendField(typeAllUUID16, u.b)
		case l == 16 && fit:
			a.AppendField(typeAllUUID128, u.b)
		case l == 2 && !fit:
			a.AppendField(typeSomeUUID16, u.b)
		case l == 16 && !fit:
			a.AppendField(typeSomeUUID128, u.b)
		}
	}
	return fit
}
1165417
func (d Device) UUID() (string, error) {
	if C.nvmlHandle == nil {
		return "", errLibraryNotLoaded
	}
	var uuid [szUUID]C.char
	r := C.nvmlDeviceGetUUID(d.dev, &uuid[0], szUUID)
	return C.GoString(&uuid[0]), errorString(r)
}
826679
func (c *Chain) Append(fn MiddlewareHandlerFunc) {
	c.middlewareHandlers = append(c.middlewareHandlers, fn)
}
1335392
func (t *TokenIntrospectionHandlers) Append(h TokenIntrospector) {
	for _, this := range *t {
		if reflect.TypeOf(this) == reflect.TypeOf(h) {
			return
		}
	}

	*t = append(*t, h)
}
37546
func (t *Tags) Append(tag Tag) {
	t.values = append(t.values, tag)
}
439430
func (w *l2capWriter) WriteFit(b []byte) bool {
	if w.chunked {
		w.chunk = append(w.chunk, b...)
		return true
	}
	avail := w.mtu - len(w.b)
	if avail >= len(b) {
		w.b = append(w.b, b...)
		return true
	}
	w.b = append(w.b, b[:avail]...)
	return false
}
2093
func (e Encoder) AppendUint(dst []byte, val uint) []byte {
	return e.AppendInt64(dst, int64(val))
}
85149
func appendStringify(buf []byte, s string) []byte {
	if mustMarshalString(s) {
		b, _ := jsongo.Marshal(s)
		return append(buf, b...)
	}
	buf = append(buf, '"')
	buf = append(buf, s...)
	buf = append(buf, '"')
	return buf
}
728098
func (r *Result) Append(val *resource.Info) {
	*r = append(*r, val)
}
799213
func (mr *MockBytesMockRecorder) Append(arg0 interface{}) *gomock.Call {
	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Append", reflect.TypeOf((*MockBytes)(nil).Append), arg0)
}
1177497
func (r *RouteAppenderAggregator) AddAppender(router types.RouteAppender) {
	r.appenders = append(r.appenders, router)
}
984547
func (Encoder) AppendUint(dst []byte, val uint) []byte {
	return strconv.AppendUint(dst, uint64(val), 10)
}
1188525
func (h Handler) Append(router *mux.Router) {
	if h.Debug {
		DebugHandler{}.Append(router)
	}

	router.Methods(http.MethodGet).Path("/api/rawdata").HandlerFunc(h.getRawData)
	router.Methods(http.MethodGet).Path("/api/providers").HandlerFunc(h.getProvidersHandler)
	router.Methods(http.MethodGet).Path("/api/providers/{provider}").HandlerFunc(h.getProviderHandler)
	router.Methods(http.MethodGet).Path("/api/providers/{provider}/routers").HandlerFunc(h.getRoutersHandler)
	router.Methods(http.MethodGet).Path("/api/providers/{provider}/routers/{router}").HandlerFunc(h.getRouterHandler)
	router.Methods(http.MethodGet).Path("/api/providers/{provider}/middlewares").HandlerFunc(h.getMiddlewaresHandler)
	router.Methods(http.MethodGet).Path("/api/providers/{provider}/middlewares/{middleware}").HandlerFunc(h.getMiddlewareHandler)
	router.Methods(http.MethodGet).Path("/api/providers/{provider}/services").HandlerFunc(h.getServicesHandler)
	router.Methods(http.MethodGet).Path("/api/providers/{provider}/services/{service}").HandlerFunc(h.getServiceHandler)

	// FIXME stats
	// health route
	//router.Methods(http.MethodGet).Path("/health").HandlerFunc(p.getHealthHandler)

	version.Handler{}.Append(router)

	if h.Dashboard {
		DashboardHandler{Assets: h.DashboardAssets}.Append(router)
	}
}
1122258
func (h *HCI) AdvertiseNameAndServices(name string, uuids ...ble.UUID) error {
	ad, err := adv.NewPacket(adv.Flags(adv.FlagGeneralDiscoverable | adv.FlagLEOnly))
	if err != nil {
		return err
	}
	f := adv.AllUUID

	// Current length of ad packet plus two bytes of length and tag.
	l := ad.Len() + 1 + 1
	for _, u := range uuids {
		l += u.Len()
	}
	if l > adv.MaxEIRPacketLength {
		f = adv.SomeUUID
	}
	for _, u := range uuids {
		if err := ad.Append(f(u)); err != nil {
			if err == adv.ErrNotFit {
				break
			}
			return err
		}
	}
	sr, _ := adv.NewPacket()
	switch {
	case ad.Append(adv.CompleteName(name)) == nil:
	case sr.Append(adv.CompleteName(name)) == nil:
	case sr.Append(adv.ShortName(name)) == nil:
	}
	if err := h.SetAdvertisement(ad.Bytes(), sr.Bytes()); err != nil {
		return nil
	}
	return h.Advertise()
}
1034502
func (t *Tuple) Append(value interface{}) {
	t.Values = append(t.Values, value)
}
620786
func (m *RTMetrics) Append(other *RTMetrics) error {
	if m == other {
		return errors.New("RTMetrics cannot append to self")
	}

	if err := m.total.Append(other.total); err != nil {
		return err
	}

	if err := m.netErrors.Append(other.netErrors); err != nil {
		return err
	}

	copied := other.Export()

	m.statusCodesLock.Lock()
	defer m.statusCodesLock.Unlock()
	m.histogramLock.Lock()
	defer m.histogramLock.Unlock()
	for code, c := range copied.statusCodes {
		o, ok := m.statusCodes[code]
		if ok {
			if err := o.Append(c); err != nil {
				return err
			}
		} else {
			m.statusCodes[code] = c.Clone()
		}
	}

	return m.histogram.Append(copied.histogram)
}
586532
func (c HandlerChain) Append(h ...Handler) HandlerChain {
	_c := make(HandlerChain, len(c)+len(h))
	copy(_c, c)
	copy(_c[len(c):], h)
	return _c
}