Utility methods for Int64 needed in the Protobuf/gRPC context.
toSignedString : Protobuf.Types.Int64.Int64 -> String
Interpret a Int64
as an unsigned integer, and give its string representation.
toSignedString (fromInt 10)
--> "10"
toSignedString (fromInt -10)
--> "-10"
toUnsignedString : Protobuf.Types.Int64.Int64 -> String
Interpret a Int64
as an unsigned integer, and give its string representation
toUnsignedString (fromInt 10)
--> "10"
toUnsignedString (fromInt -10)
--> "18446744073709551606"
fromSignedString : String -> Maybe Protobuf.Types.Int64.Int64
Parse a signed Int64 from its string representation
fromSignedString "10"
--> Just (Int64 { higher = 0, lower = 10 })
fromSignedString "-10"
--> Just (Int64 { higher = -1, lower = -10 })
fromSignedString "not-a-number"
--> Nothing
fromSignedString "9223372036854775807"
--> Just (Int64 { higher = 2147483647, lower = -1 })
fromSignedString "-9223372036854775808"
--> Just (Int64 { higher = -2147483648, lower = 0 })
fromSignedString "-9223372036854775809"
--> Nothing
fromUnsignedString : String -> Maybe Protobuf.Types.Int64.Int64
Parse an unsigned Int64 from its string representation
fromUnsignedString "10"
--> Just (Int64 { higher = 0, lower = 10 })
fromUnsignedString "-10"
--> Nothing
fromUnsignedString "not-a-number"
--> Nothing
fromUnsignedString "9223372036854775807"
--> Just (Int64 { higher = 2147483647, lower = -1 })
fromUnsignedString "18446744073709551615"
--> Just (Int64 { higher = -1, lower = -1 })
fromUnsignedString "18446744073709551616"
--> Nothing
fromInt : Basics.Int -> Protobuf.Types.Int64.Int64
Constructs an Int64 from an Int. The Int can be bigger than 32-bit, you can expect Integers in the safe int range in JS (-(2^53 - 1) to 2^53 - 1) to work.
toIntUnsafe : Protobuf.Types.Int64.Int64 -> Basics.Int
Attempts to convert the Int64 into a JS Int. This should be safe for the safe int range in JS (-(2^53 - 1) to 2^53 - 1). Expect weird results for anything outside that range.
int64JsonDecoder : Json.Decode.Decoder Protobuf.Types.Int64.Int64
Decodes an Int64 from a signed integer JSON string (i.e. {"key": "-123456789"}) or a JSON number literal (i.e. {"key": -123})
uint64JsonDecoder : Json.Decode.Decoder Protobuf.Types.Int64.Int64
Decodes an Int64 from an unsigned integer JSON string (i.e. {"key": "123456789"}) or a JSON number literal (i.e. {"key": 123})
int64JsonEncoder : Protobuf.Types.Int64.Int64 -> Json.Encode.Value
Encodes an Int64 as a signed integer JSON string
uint64JsonEncoder : Protobuf.Types.Int64.Int64 -> Json.Encode.Value
Encodes an Int64 as an unsigned integer JSON string