MCPcopy
hub / github.com/tinode/chat / NewObjState

Function NewObjState

server/store/types/types.go:454–468  ·  view source on GitHub ↗

NewObjState parses string into an ObjState.

(in string)

Source from the content-addressed store, hash-verified

452
453// NewObjState parses string into an ObjState.
454func NewObjState(in string) (ObjState, error) {
455 in = strings.ToLower(in)
456 switch in {
457 case "", "ok":
458 return StateOK, nil
459 case "susp":
460 return StateSuspended, nil
461 case "del":
462 return StateDeleted, nil
463 case "undef":
464 return StateUndefined, nil
465 }
466 // This is the default.
467 return StateOK, errors.New("failed to parse object state")
468}
469
470// MarshalJSON converts ObjState to a quoted string.
471func (os ObjState) MarshalJSON() ([]byte, error) {

Callers 4

genDbFunction · 0.92
replyCreateUserFunction · 0.92
changeUserStateFunction · 0.92
UnmarshalJSONMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…