MCPcopy Index your code
hub / github.com/Preloading/TwitterAPIBridge / TidToNum

Function TidToNum

bridge/tidconversions.go:36–56  ·  view source on GitHub ↗

tidToNum converts a Bluesky TID into a 64-bit number.

(tid string)

Source from the content-addressed store, hash-verified

34
35// tidToNum converts a Bluesky TID into a 64-bit number.
36func TidToNum(tid string) (uint64, error) {
37 if len(tid) != 13 {
38 return 0, fmt.Errorf("TID must be 13 characters")
39 }
40
41 var num uint64
42 for _, c := range tid {
43 index := strings.IndexRune(tidChars, c)
44 if index == -1 {
45 return 0, fmt.Errorf("invalid character in TID: %c", c)
46 }
47 num = (num << 5) | uint64(index)
48 }
49
50 // Verify the first bit is 0
51 if (num & 0x8000000000000000) != 0 {
52 return 0, fmt.Errorf("first bit must be 0")
53 }
54
55 return num, nil
56}

Callers 4

GetUsersListsFunction · 0.92
GetListMembersFunction · 0.92
GetFollowersFunction · 0.92
GetFollowsFunction · 0.92

Calls

no outgoing calls

Tested by

no test coverage detected