View Source Babel.Fetchable protocol (Babel v1.1.0)

The protocol which enables Babel.fetch/1 and Babel.get/2.

Babel ships with implementations for:

The fallback Any implementation treats any struct as a Map.

Summary

Types

t()

Anything that implements this protocol.

Functions

Fetch the given path from the data

Types

@type implementation() ::
  Babel.Fetchable.Any
  | Babel.Fetchable.Map
  | Babel.Fetchable.List
  | Babel.Fetchable.Tuple
@type t() :: term()

Anything that implements this protocol.

Has default implementations for Map, List, and Tuple, and a fallback for structs.

Functions

@spec fetch(data, path) ::
  {:ok, any()}
  | :error
  | {:error, {:not_implemented, Babel.Fetchable, data}}
  | {:error, {:not_supported, implementation(), path}}
when data: any(), path: any()

Fetch the given path from the data