-
Notifications
You must be signed in to change notification settings - Fork 90
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update specs #157
Update specs #157
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,14 +21,15 @@ defmodule Geo.WKB do | |
Takes a Geometry and returns a WKB string. The endian decides | ||
what the byte order will be. | ||
""" | ||
@spec encode!(Geo.geometry(), Geo.endian()) :: binary | no_return | ||
@spec encode!(Geo.geometry(), Geo.endian()) :: binary | ||
def encode!(geom, endian \\ :xdr) do | ||
geom |> Encoder.encode!(endian) |> IO.iodata_to_binary() |> Base.encode16() | ||
end | ||
|
||
@doc """ | ||
Takes a Geometry and returns a WKB string. The endian decides | ||
what the byte order will be. | ||
Takes a Geometry and returns a WKB string. | ||
|
||
The endian decides what the byte order will be. | ||
""" | ||
@spec encode(binary, Geo.endian()) :: {:ok, binary} | {:error, Exception.t()} | ||
def encode(geom, endian \\ :xdr) do | ||
|
@@ -39,10 +40,11 @@ defmodule Geo.WKB do | |
end | ||
|
||
@doc """ | ||
Takes a Geometry and returns a WKB as iodata. The endian decides | ||
what the byte order will be. | ||
Takes a Geometry and returns a WKB as iodata. | ||
|
||
The endian decides what the byte order will be. | ||
""" | ||
@spec encode_to_iodata(Geo.geometry(), Geo.endian()) :: iodata() | no_return | ||
@spec encode_to_iodata(Geo.geometry(), Geo.endian()) :: iodata() | ||
def encode_to_iodata(geom, endian \\ :xdr) do | ||
Encoder.encode!(geom, endian) | ||
end | ||
|
@@ -79,7 +81,7 @@ defmodule Geo.WKB do | |
@doc """ | ||
Takes a WKB string and returns a Geometry. | ||
""" | ||
@spec decode!(binary | iodata()) :: Geo.geometry() | no_return | ||
@spec decode!(iodata()) :: Geo.geometry() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I really don't think there's a use case for accepting an iodata, I'm happy to send a PR which removes the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Removing the |
||
def decode!(wkb) | ||
|
||
def decode!("00" <> _ = wkb) do | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no_return should be used when the function never returns (always raises, throws, endlessly loops, etc). Otherwise we'd need to annotate almost every function as they may e.g. raise an exception for invalid args, function clause, etc!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah got it. That makes sense