Skip to content

Commit

Permalink
Fix json_decode! typespec
Browse files Browse the repository at this point in the history
Closes #79
  • Loading branch information
ahamez committed Oct 14, 2021
1 parent 9390666 commit 7a881c6
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions lib/protox/define_message.ex
Original file line number Diff line number Diff line change
Expand Up @@ -89,17 +89,7 @@ defmodule Protox.DefineMessage do
end
end

@spec json_encode(struct(), keyword()) :: {:ok, iodata()} | {:error, any()}
def json_encode(msg, opts \\ []) do
try do
{:ok, json_encode!(msg, opts)}
rescue
e in Protox.JsonEncodingError ->
{:error, e}
end
end

@spec json_decode!(iodata(), keyword()) :: iodata() | no_return()
@spec json_decode!(iodata(), keyword()) :: struct() | no_return()

This comment has been minimized.

Copy link
@jacek-adamek

jacek-adamek Oct 14, 2021

Thanks!

def json_decode!(input, opts \\ []) do
{json_library_wrapper, json_library} = Protox.JsonLibrary.get_library(opts, :decode)

Expand All @@ -110,6 +100,16 @@ defmodule Protox.DefineMessage do
)
end

@spec json_encode(struct(), keyword()) :: {:ok, iodata()} | {:error, any()}
def json_encode(msg, opts \\ []) do
try do
{:ok, json_encode!(msg, opts)}
rescue
e in Protox.JsonEncodingError ->
{:error, e}
end
end

@spec json_encode!(struct(), keyword()) :: iodata() | no_return()
def json_encode!(msg, opts \\ []) do
{json_library_wrapper, json_library} = Protox.JsonLibrary.get_library(opts, :encode)
Expand Down

0 comments on commit 7a881c6

Please sign in to comment.