// fromState parses the oauth state parameter from r to extract the blobRef of the
// instance configuration and the xsrftoken that were stored during serveSetup.
763622
func fromState(r *http.Request) (br blob.Ref, xsrfToken string, err error) {
	params := strings.Split(r.FormValue("state"), ":")
	if len(params) != 2 {
		return br, "", fmt.Errorf("Invalid format for state parameter: %q, wanted blobRef:xsrfToken", r.FormValue("state"))
	}
	br, ok := blob.Parse(params[0])
	if !ok {
		return br, "", fmt.Errorf("Invalid blobRef in state parameter: %q", params[0])
	}
	token, err := hex.DecodeString(params[1])
	if err != nil {
		return br, "", fmt.Errorf("can't decode hex xsrftoken %q: %v", params[1], err)
	}
	return br, string(token), nil
}
933240
func (d *Dispatcher) GetUserState(u mbotapi.User) (State, error) {
	if s, ok := d.Storage[u]; ok {
		return s, nil
	}
	return State{}, ErrNoCurrentState
}
1159973
func (v *Libravatar) FromURL(openid string) (string, error) {
	ourl, err := url.Parse(openid)
	if err != nil {
		return "", err
	}

	if !ourl.IsAbs() {
		return "", fmt.Errorf("Is not an absolute URL")
	} else if ourl.Scheme != "http" && ourl.Scheme != "https" {
		return "", fmt.Errorf("Invalid protocol: %s", ourl.Scheme)
	}

	link, err := v.process(nil, ourl)
	if err != nil {
		return "", err
	}

	return link, nil
}
774549
func (c *Ctx) SetOperationState(sh SessionHandle, state []byte, encryptKey, authKey ObjectHandle) error {
	e := C.SetOperationState(c.ctx, C.CK_SESSION_HANDLE(sh), C.CK_BYTE_PTR(unsafe.Pointer(&state[0])),
		C.CK_ULONG(len(state)), C.CK_OBJECT_HANDLE(encryptKey), C.CK_OBJECT_HANDLE(authKey))
	return toError(e)
}
1292199
func (s *Trust) SetTrustState(v string) *Trust {
	s.TrustState = &v
	return s
}
762043
func ToETLState(s string) (ETLState, error) {
	st := ETLState(s)
	switch st {
	case EtlOn:
		return EtlOn, nil
	case EtlOff:
		return EtlOff, nil
	default:
		return EtlOff, fmt.Errorf("%s: %s", errUnrecognizedETLState, s)
	}
}
656626
func (c *Client) GetAllocState(allocID string) (*arstate.State, error) {
	ar, err := c.getAllocRunner(allocID)
	if err != nil {
		return nil, err
	}

	return ar.AllocState(), nil
}
1046219
func (c *Container) FromDisk() error {
	jsonSource, err := os.Open(c.StatePath())
	if err != nil {
		return err
	}
	defer jsonSource.Close()

	dec := json.NewDecoder(jsonSource)
	return dec.Decode(c.state)
}
1174654
func (p *PullRequest) GetMergeableState() string {
	if p == nil || p.MergeableState == nil {
		return ""
	}
	return *p.MergeableState
}
663901
func NewSNSTaskState(stateName string,
	parameters SNSTaskParameters) *SNSTaskState {

	sns := &SNSTaskState{
		BaseTask: BaseTask{
			baseInnerState: baseInnerState{
				name: stateName,
				id:   rand.Int63(),
			},
		},
		parameters: parameters,
	}
	return sns
}
879106
func (bc *BlockChain) HasState(hash common.Hash) bool {
	_, err := bc.stateCache.OpenTrie(hash)
	return err == nil
}
595663
func WithState(c context.Context, s State) context.Context {
	return context.WithValue(c, stateContextKey(0), s)
}
1328532
func FromBytes(input []byte) (u UUID, err error) {
	err = u.UnmarshalBinary(input)
	return
}
1261396
func (t *Transition) From(from uint8) *Transition {
	t.from = from
	t.fromSet = true
	t.recalculate()
	return t
}
1338585
func (db *StakeDatabase) DBState() (uint32, *chainhash.Hash, error) {
	db.nodeMtx.RLock()
	defer db.nodeMtx.RUnlock()

	return db.dbState()
}
178122
func (d *decoder) pushState(s json.Delim) {
	d.parseState = append(d.parseState, s)
}
394809
func deploymentState(deployment *deployment, ctx *context) stateFn {
	_, err := deployment.client.CreateApp(deployment.application)
	time.Sleep(2000 * time.Millisecond)
	if err != nil {
		deployment.status.code = FAIL
		deployment.status.message = fmt.Sprintf("%s", err)
		log.Printf("Error Deployment: %s - %s", deployment.application.ID, err)
		return nil
	}
	return postActionState
}