// Save implements the interface method.
198589
func (rr *rasterRenderer) Save(w io.Writer) error {
	if typed, isTyped := w.(RGBACollector); isTyped {
		typed.SetRGBA(rr.i)
		return nil
	}
	return png.Encode(w, rr.i)
}
828233
func (c *Connection) Save(model interface{}, excludeColumns ...string) error {
	sm := &Model{Value: model}
	return sm.iterate(func(m *Model) error {
		id, err := m.fieldByName("ID")
		if err != nil {
			return err
		}
		if IsZeroOfUnderlyingType(id.Interface()) {
			return c.Create(m.Value, excludeColumns...)
		}
		return c.Update(m.Value, excludeColumns...)
	})
}
889899
func (c Config) Save(file string) error {
	var s = fileOutput(c.root)
	return ioutil.WriteFile(file, []byte(s), 0666)
}
572320
func (d *Database) Save(db DB, table string, src interface{}) error {
	pkName, pkValue, err := d.PrimaryKey(src)
	if err != nil {
		return err
	}
	if pkName != "" && pkValue != 0 {
		return d.Update(db, table, src)
	}

	return d.Insert(db, table, src)
}
345447
func Save(path string, data interface{}) error {
	err := os.MkdirAll(filepath.Dir(path), os.ModeDir+0666)
	if err != nil {
		return err
	}
	file, err := os.Create(path)
	if err != nil {
		return err
	}
	defer file.Close()
	buf, err := json.MarshalIndent(data, "", "    ")
	if err != nil {
		return err
	}
	_, err = io.Copy(file, bytes.NewReader(buf))
	return err
}
1006949
func (player *Player) Save() error {
	var err error
	if db.DB.NewRecord(player) {
		err = db.DB.Create(player).Error
	} else {
		err = db.DB.Save(player).Error
	}
	return err
}
606895
func (s *RethinkStore) save(session *sessions.Session) error {
	buf := new(bytes.Buffer)
	enc := gob.NewEncoder(buf)
	err := enc.Encode(session.Values)
	if err != nil {
		return err
	}

	age := session.Options.MaxAge
	if age == 0 {
		age = s.DefaultMaxAge
	}
	expires := time.Now().Add(time.Duration(age) * time.Second)

	_, err = r.Table(s.Table).Get(session.ID).Replace(RethinkSession{Id: session.ID, Expires: expires, Session: buf.Bytes()}).Run(s.Rethink)
	return err
}
1215070
func (proxy *Proxy) Save() error {
	request, err := json.Marshal(proxy)
	if err != nil {
		return err
	}

	var resp *http.Response
	if proxy.created {
		resp, err = http.Post(proxy.client.endpoint+"/proxies/"+proxy.Name, "text/plain", bytes.NewReader(request))
	} else {
		resp, err = http.Post(proxy.client.endpoint+"/proxies", "application/json", bytes.NewReader(request))
	}
	if err != nil {
		return err
	}

	if proxy.created {
		err = checkError(resp, http.StatusOK, "Save")
	} else {
		err = checkError(resp, http.StatusCreated, "Create")
	}
	if err != nil {
		return err
	}

	err = json.NewDecoder(resp.Body).Decode(proxy)
	if err != nil {
		return err
	}
	proxy.created = true

	return nil
}
1076271
func (s *CookieStore) Save(w http.ResponseWriter, session *Session) error {
	cookieValue, err := securecookie.EncodeMulti(session.Name(), &session.Values, s.Codecs...)
	if err != nil {
		return err
	}
	http.SetCookie(w, newCookie(session.Name(), cookieValue, session.Config))
	return nil
}
942826
func (c Config) Save() error {
	bs, err := json.MarshalIndent(c, "", "    ")
	if err != nil {
		log.Debug(err)
		return errors.New("unable to save config file")
	}

	configPath := filepath.Join(ConfigDir(), ConfigFileName)

	fi, err := os.Stat(configPath)
	if err != nil {
		log.Debug(err)
		return errors.New("unable to save config file")
	}

	if err = ioutil.WriteFile(configPath, bs, fi.Mode()); err != nil {
		log.Debug(err)
		return errors.New("unable to save config file")
	}

	return nil
}
848873
func (c *Challenge) Save(w http.ResponseWriter, r *http.Request) error {
	session, err := c.idp.config.ChallengeStore.New(r, SessionCookieName)
	if err != nil {
		return err
	}

	session.Options = c.idp.createChallengeCookieOptions
	session.Values[SessionCookieName] = c

	return c.idp.config.ChallengeStore.Save(r, w, session)
}
223808
func (d config) Save(filename string) error {
	d.lock.Lock()
	defer d.lock.Unlock()

	if d.clnt != nil {
		return saveFileConfigEtcd(filename, d.clnt, d.data)
	}

	// Backup if given file exists
	oldData, err := ioutil.ReadFile(filename)
	if err != nil {
		// Ignore if file does not exist.
		if !os.IsNotExist(err) {
			return err
		}
	} else {
		// Save read data to the backup file.
		backupFilename := filename + ".old"
		if err = writeFile(backupFilename, oldData); err != nil {
			return err
		}
	}

	// Save data.
	return saveFileConfig(filename, d.data)
}
587576
func (db *memDB) Save(c *Container) error {
	return db.withTxn(func(txn *memdb.Txn) error {
		return txn.Insert(memdbContainersTable, c)
	})
}
1181205
func (configFile *ConfigFile) Save() error {
	if configFile.Filename == "" {
		return errors.Errorf("Can't save config with empty filename")
	}

	dir := filepath.Dir(configFile.Filename)
	if err := os.MkdirAll(dir, 0700); err != nil {
		return err
	}
	temp, err := ioutil.TempFile(dir, filepath.Base(configFile.Filename))
	if err != nil {
		return err
	}
	err = configFile.SaveToWriter(temp)
	temp.Close()
	if err != nil {
		os.Remove(temp.Name())
		return err
	}
	return os.Rename(temp.Name(), configFile.Filename)
}
1109782
func (s *FileSystemStorage) Save(filepath string, file File) error {
	return s.SaveWithPermissions(filepath, file, DefaultFilePermissions)
}
76264
func (n *node) Save(data interface{}) error {
	ref := reflect.ValueOf(data)

	if !ref.IsValid() || ref.Kind() != reflect.Ptr || ref.Elem().Kind() != reflect.Struct {
		return ErrStructPtrNeeded
	}

	cfg, err := extract(&ref)
	if err != nil {
		return err
	}

	if cfg.ID.IsZero {
		if !cfg.ID.IsInteger || !cfg.ID.Increment {
			return ErrZeroID
		}
	}

	return n.readWriteTx(func(tx *bolt.Tx) error {
		return n.save(tx, cfg, data, false)
	})
}
1015125
func (rwt *RWTree) Save() ([]byte, int64, error) {
	// save state at a new version may still be orphaned before we save the version against the hash
	hash, version, err := rwt.tree.SaveVersion()
	if err != nil {
		return nil, 0, fmt.Errorf("could not save RWTree: %v", err)
	}
	// Take an immutable reference to the tree we just saved for querying
	rwt.ImmutableTree, err = rwt.tree.GetImmutable(version)
	if err != nil {
		return nil, 0, fmt.Errorf("RWTree.Save() could not obtain ImmutableTree read tree: %v", err)
	}
	rwt.updated = false
	return hash, version, nil
}