MCPcopy Create free account
hub / github.com/pion/ice / readCandidateDigitToken

Function readCandidateDigitToken

candidate_base.go:981–1001  ·  view source on GitHub ↗

Read a digit token from the raw string stop reading when a space is encountered or the end of the string.

(raw string, start, limit int)

Source from the content-addressed store, hash-verified

979// Read a digit token from the raw string
980// stop reading when a space is encountered or the end of the string.
981func readCandidateDigitToken(raw string, start, limit int) (int, int, error) {
982 var val int
983 for i, char := range raw[start:] {
984 if char == 0x20 { // SP
985 return val, start + i + 1, nil
986 }
987
988 if i == limit {
989 //nolint: err113 // handled by caller
990 return 0, 0, fmt.Errorf("token too long: %s expected 1x%d", raw[start:start+i], limit)
991 }
992
993 if char < '0' || char > '9' {
994 return 0, 0, fmt.Errorf("invalid digit token: %c", char) //nolint: err113 // handled by caller
995 }
996
997 val = val*10 + int(char-'0')
998 }
999
1000 return val, len(raw), nil
1001}
1002
1003// Read and validate RFC 4566 port from the raw string.
1004func readCandidatePort(raw string, start int) (int, int, error) {

Callers 2

UnmarshalCandidateFunction · 0.85
readCandidatePortFunction · 0.85

Calls 1

ErrorfMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…