zf

zenflows testing
git clone https://s.sonu.ch/~srfsh/zf.git
Log | Files | Refs | Submodules | README | LICENSE

xid8.ex (589B)


      1 defmodule Postgrex.Extensions.Xid8 do
      2   @moduledoc false
      3   import Postgrex.BinaryUtils, warn: false
      4   use Postgrex.BinaryExtension, send: "xid8send"
      5 
      6   @xid8_range 0..18_446_744_073_709_551_615
      7 
      8   def encode(_) do
      9     range = Macro.escape(@xid8_range)
     10 
     11     quote location: :keep do
     12       int when int in unquote(range) ->
     13         <<8::int32(), int::uint64()>>
     14 
     15       other ->
     16         raise DBConnection.EncodeError, Postgrex.Utils.encode_msg(other, unquote(range))
     17     end
     18   end
     19 
     20   def decode(_) do
     21     quote location: :keep do
     22       <<8::int32(), int::uint64()>> -> int
     23     end
     24   end
     25 end