// PageState sets the paging state for the query to resume paging from a specific
// point in time. Setting this will disable to query paging for this query, and
// must be used for all subsequent pages.
353434
func (q *Query) PageState(state []byte) *Query {
	q.pageState = state
	q.disableAutoPage = true
	return q
}
106286
func (s *AwsSecurityFinding) SetRecordState(v string) *AwsSecurityFinding {
	s.RecordState = &v
	return s
}
317042
func (api *ServerAPI) State(id int64) (string, error) {
	server, err := api.Read(id)
	if err != nil {
		return "", err
	}
	return string(server.Availability), nil
}
109217
func (s *StepExecutionStatusDetail) SetState(v string) *StepExecutionStatusDetail {
	s.State = &v
	return s
}
332216
func (p *Paginater) Pages() []*Page {
	if p.numPages == 0 {
		return []*Page{}
	} else if p.numPages == 1 && p.TotalPages() == 1 {
		// Only show current page.
		return []*Page{{1, true}}
	}

	// Total page number is less or equal.
	if p.TotalPages() <= p.numPages {
		pages := make([]*Page, p.TotalPages())
		for i := range pages {
			pages[i] = &Page{i + 1, i+1 == p.current}
		}
		return pages
	}

	numPages := p.numPages
	maxIdx := numPages - 1
	offsetIdx := 0
	hasMoreNext := false

	// Check more previous and next pages.
	previousNum := getMiddleIdx(p.numPages) - 1
	if previousNum > p.current-1 {
		previousNum -= previousNum - (p.current - 1)
	}
	nextNum := p.numPages - previousNum - 1
	if p.current+nextNum > p.TotalPages() {
		delta := nextNum - (p.TotalPages() - p.current)
		nextNum -= delta
		previousNum += delta
	}

	offsetVal := p.current - previousNum
	if offsetVal > 1 {
		numPages++
		maxIdx++
		offsetIdx = 1
	}

	if p.current+nextNum < p.TotalPages() {
		numPages++
		hasMoreNext = true
	}

	pages := make([]*Page, numPages)

	// There are more previous pages.
	if offsetIdx == 1 {
		pages[0] = &Page{-1, false}
	}
	// There are more next pages.
	if hasMoreNext {
		pages[len(pages)-1] = &Page{-1, false}
	}

	// Check previous pages.
	for i := 0; i < previousNum; i++ {
		pages[offsetIdx+i] = &Page{i + offsetVal, false}
	}

	pages[offsetIdx+previousNum] = &Page{p.current, true}

	// Check next pages.
	for i := 1; i <= nextNum; i++ {
		pages[offsetIdx+previousNum+i] = &Page{p.current + i, false}
	}

	return pages
}
1201337
func (client *Client) PaginateRunstatusServices(ctx context.Context, page RunstatusPage, callback func(*RunstatusService, error) bool) { // nolint: dupl
	if page.ServicesURL == "" {
		callback(nil, fmt.Errorf("empty Services URL for %#v", page))
		return
	}

	servicesURL := page.ServicesURL
	for servicesURL != "" {
		resp, err := client.runstatusRequest(ctx, servicesURL, nil, "GET")
		if err != nil {
			callback(nil, err)
			return
		}

		var ss *RunstatusServiceList
		if err := json.Unmarshal(resp, &ss); err != nil {
			callback(nil, err)
			return
		}

		for i := range ss.Services {
			if err := ss.Services[i].FakeID(); err != nil {
				log.Printf("bad fake ID for %#v, %s", ss.Services[i], err)
			}

			if cont := callback(&ss.Services[i], nil); !cont {
				return
			}
		}

		servicesURL = ss.Next
	}
}
332511
func (a *MobileAppState) State() keybase1.MobileAppState {
	a.Lock()
	defer a.Unlock()
	return a.state
}
246330
func (s *ReservedCacheNode) SetState(v string) *ReservedCacheNode {
	s.State = &v
	return s
}
264771
func (f *FSM) SetState(state string) {
	f.stateMu.Lock()
	defer f.stateMu.Unlock()
	f.current = state
	return
}
259936
func (s *DiskSnapshot) SetState(v string) *DiskSnapshot {
	s.State = &v
	return s
}
932614
func (p *Parser) NewState(sym rune) State {
	var found State

	found = &LowerCaseState{}
	if found.StartSym(sym) {
		return found
	}

	found = &UpperCaseState{}
	if found.StartSym(sym) {
		return found
	}

	found = &NumberCaseState{}
	if found.StartSym(sym) {
		return found
	}

	return &NonAlphaNumericCaseState{}
}
645035
func (s *CreateLifecyclePolicyInput) SetState(v string) *CreateLifecyclePolicyInput {
	s.State = &v
	return s
}
243422
func NewState(caller base.APICaller) *State {
	facadeCaller := base.NewFacadeCaller(caller, provisionerFacade)
	return NewStateFromFacade(facadeCaller)
}
1291258
func (c ClientCookies) SetState(w http.ResponseWriter, r *http.Request, id string, value string) {
	http.SetCookie(w, &http.Cookie{
		Name:     stateCookiePrefix + id,
		Value:    value,
		MaxAge:   int(saml.MaxIssueDelay.Seconds()),
		HttpOnly: true,
		Secure:   c.Secure || r.URL.Scheme == "https",
		Path:     c.ServiceProvider.AcsURL.Path,
	})
}
1187657
func Paging(limit, offset int) QueryOpt {
	return QueryOpt{func(o *QueryOptions) {
		o.Limit = limit
		o.Offset = offset
	}}
}
23479
func (s *Stat) PageStats() *PageStats {
	s.Lock()
	defer s.Unlock()

	var p *PageStats

	do(func() {
		pstats := C.sg_get_page_stats_diff(nil)

		p = &PageStats{
			PageIn:    int(pstats.pages_pagein),
			PageOut:   int(pstats.pages_pageout),
			Period:    time.Duration(int(pstats.systime)),
			TimeTaken: time.Now(),
		}
	})
	return p
}
648095
func (tsv *TabletServer) setState(state int64) {
	log.Infof("TabletServer state: %s -> %s", stateInfo(tsv.state), stateInfo(state))
	tsv.state = state
	tsv.history.Add(&historyRecord{
		Time:         time.Now(),
		ServingState: stateInfo(state),
		TabletType:   tsv.target.TabletType.String(),
	})
}