// ReplaceSettings exposes replaceSettings on state for use outside the state package.
544707
func (s *StateSettings) ReplaceSettings(key string, settings map[string]interface{}) error {
	return replaceSettings(s.backend.db(), s.collection, key, settings)
}
491680
func (s *CaptionDescription) SetDestinationSettings(v *CaptionDestinationSettings) *CaptionDescription {
	s.DestinationSettings = v
	return s
}
897962
func (s *Preset) SetSettings(v *PresetSettings) *Preset {
	s.Settings = v
	return s
}
437367
func (s *Session) UserSettings() (st *Settings, err error) {

	body, err := s.RequestWithBucketID("GET", EndpointUserSettings("@me"), nil, EndpointUserSettings(""))
	if err != nil {
		return
	}

	err = unmarshal(body, &st)
	return
}
6422
func ParseSettings(b []byte) []http2.Setting {
	var r []http2.Setting
	for i := 0; i < len(b)/6; i++ {
		r = append(r, http2.Setting{
			ID:  http2.SettingID(binary.BigEndian.Uint16(b[i*6:])),
			Val: binary.BigEndian.Uint32(b[i*6+2:]),
		})
	}
	return r
}
529647
func (s *CreatePlatformVersionInput) SetOptionSettings(v []*ConfigurationOptionSetting) *CreatePlatformVersionInput {
	s.OptionSettings = v
	return s
}
152614
func (s *Stage) SetRouteSettings(v map[string]*RouteSettings) *Stage {
	s.RouteSettings = v
	return s
}
187189
func (s *HlsGroupSettings) SetKeyProviderSettings(v *KeyProviderSettings) *HlsGroupSettings {
	s.KeyProviderSettings = v
	return s
}
1293762
func (BasePage) WriteSettings(c context.Context, values map[string]string, who, why string) error {
	return errors.New("not implemented")
}
511227
func (s *ValidateConfigurationSettingsInput) SetOptionSettings(v []*ConfigurationOptionSetting) *ValidateConfigurationSettingsInput {
	s.OptionSettings = v
	return s
}
786318
func (s *StateSettings) RemoveSettings(key string) error {
	return removeSettings(s.backend.db(), s.collection, key)
}
101792
func (m MemSettings) RemoveSettings(key string) error {
	if _, ok := m.Settings[key]; !ok {
		return errors.NotFoundf("settings with key %q", key)
	}
	delete(m.Settings, key)
	return nil
}
500634
func updateSettings(c context.Context) error {
	// Load the settings from luci-config.
	cs := cfgclient.CurrentServiceConfigSet(c)
	lucicfg := GetConfigService(c)
	cfg, err := lucicfg.GetConfig(c, cs, "settings.cfg", false)
	if err != nil {
		return errors.Annotate(err, "loading settings.cfg from luci-config").Err()
	}

	// Do the revision check & swap in a datastore transaction.
	return datastore.RunInTransaction(c, func(c context.Context) error {
		oldSettings := Settings{}
		err := datastore.Get(c, &oldSettings)
		switch err {
		case datastore.ErrNoSuchEntity:
			// This might be the first time this has run, so a warning here is ok.
			logging.WithError(err).Warningf(c, "no existing service config")
		case nil:
			// Continue
		default:
			return errors.Annotate(err, "loading existing config").Err()
		}
		// Check to see if we need to update
		if oldSettings.Revision == cfg.Revision {
			logging.Debugf(c, "revisions matched (%s), no need to update", cfg.Revision)
			return nil
		}
		newSettings := Settings{Revision: cfg.Revision}
		if err := proto.UnmarshalText(cfg.Content, &newSettings.Settings); err != nil {
			return errors.Annotate(err, "unmarshalling proto").Err()
		}
		ctx := &validation.Context{Context: c}
		ctx.SetFile("settings.cfg")
		validateSettings(ctx, &newSettings.Settings)
		if err := ctx.Finalize(); err != nil {
			return errors.Annotate(err, "validating settings").Err()
		}
		return datastore.Put(c, &newSettings)
	}, nil)
}
969518
func (s *CaptionSelector) SetSelectorSettings(v *CaptionSelectorSettings) *CaptionSelector {
	s.SelectorSettings = v
	return s
}
1177388
func (s *PresetSettings) SetContainerSettings(v *ContainerSettings) *PresetSettings {
	s.ContainerSettings = v
	return s
}
642071
func (s *StateSettings) ReadSettings(key string) (map[string]interface{}, error) {
	if s, err := readSettings(s.backend.db(), s.collection, key); err != nil {
		return nil, err
	} else {
		return s.Map(), nil
	}
}
560251
func (s *CreatePresetInput) SetSettings(v *PresetSettings) *CreatePresetInput {
	s.Settings = v
	return s
}