feed format behaviour
This commit is contained in:
1 parent
97e2494b33
commit
3446c3aa4d
1 file changed
+22
@@ -0,0 +1,22 @@
|
||||
defmodule FeedReader.Format do
|
||||
@moduledoc """
|
||||
Behaviour implemented by built-in and explicitly supplied feed formats.
|
||||
|
||||
Detection examines only the bounded, replayable prefix provided by the caller.
|
||||
XML formats provide their dedicated Saxy handler and create parser state with
|
||||
an event sink; normalization returns the standalone feed and item value types.
|
||||
"""
|
||||
|
||||
@callback id() :: atom()
|
||||
@callback detect(prefix :: binary()) :: :match | :no_match
|
||||
@callback handler() :: module()
|
||||
@callback new_parser_state(event_sink :: function(), opts :: keyword()) :: term()
|
||||
|
||||
@callback normalize_feed(state :: term(), opts :: keyword()) :: FeedReader.Feed.t()
|
||||
|
||||
@callback normalize_item(
|
||||
raw_item :: map(),
|
||||
feed :: FeedReader.Feed.t(),
|
||||
opts :: keyword()
|
||||
) :: {:ok, FeedReader.Item.t()} | :skip | {:error, term()}
|
||||
end
|
||||
Reference in new issue
Block a user