Skip to content

Commit 927dfb3

Browse files
committed
type cleanup
1 parent ea2e48b commit 927dfb3

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

lib/scenic/cache/hash.ex

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ defmodule Scenic.Cache.Hash do
2828
| :sha512
2929
| :ripemd160
3030

31-
@type type_error :: {:error, :invalid_hash_type}
32-
@type hash_error :: {:error, :hash_failure}
31+
# @type type_error :: {:error, :invalid_hash_type}
32+
# @type hash_error :: {:error, :hash_failure}
3333

3434
# ===========================================================================
3535
defmodule Error do
@@ -67,7 +67,8 @@ defmodule Scenic.Cache.Hash do
6767
6868
Returns the hash wrapped in a `{:ok, hash}` tuple.
6969
"""
70-
@spec binary(data :: binary, type :: hash_type) :: {:ok, bitstring()} | type_error
70+
@spec binary(data :: binary, type :: hash_type) ::
71+
{:ok, bitstring()} | {:error, :invalid_hash_type}
7172
def binary(data, type) do
7273
case valid_hash_type?(type) do
7374
true -> {:ok, type |> :crypto.hash(data) |> Base.url_encode64(padding: false)}
@@ -88,7 +89,8 @@ defmodule Scenic.Cache.Hash do
8889
end
8990

9091
# --------------------------------------------------------
91-
@spec file(path :: bitstring, type :: hash_type) :: {:ok, bitstring()} | type_error
92+
@spec file(path :: bitstring, type :: hash_type) ::
93+
{:ok, bitstring()} | {:error, :invalid_hash_type}
9294
def file(path, hash_type) do
9395
do_compute_file(
9496
path,
@@ -145,7 +147,8 @@ defmodule Scenic.Cache.Hash do
145147
If the verification passes, returns `{:ok, data}`
146148
If it fails, returns `{:error, :hash_failure}`
147149
"""
148-
@spec verify(data :: binary, hash :: bitstring, type :: hash_type) :: {:ok, binary} | hash_error
150+
@spec verify(data :: binary, hash :: bitstring, type :: hash_type) ::
151+
{:ok, binary} | {:error, :hash_failure}
149152
def verify(data, hash, hash_type) do
150153
case binary(data, hash_type) do
151154
{:ok, ^hash} -> {:ok, data}
@@ -176,7 +179,7 @@ defmodule Scenic.Cache.Hash do
176179
If it fails, returns `{:error, :hash_failure}`
177180
"""
178181
@spec verify_file(path :: bitstring, hash :: bitstring, type :: hash_type) ::
179-
binary | hash_error
182+
{:ok, binary} | {:error, :hash_failure}
180183
def verify_file(path, hash, hash_type) do
181184
case file(path, hash_type) do
182185
{:ok, computed_hash} ->

0 commit comments

Comments
 (0)