Unicode.Property.Behaviour behaviour (Unicode v2.0.0)

Copy Markdown View Source

Defines the behaviour required of modules that serve a Unicode property.

A property server maps property values to lists of codepoint ranges and resolves property value aliases. Modules implementing this behaviour include Unicode.Script, Unicode.Block, Unicode.GeneralCategory and Unicode.Property.

Summary

Callbacks

Returns a map of aliases for the property values served by the implementing module.

Returns the number of codepoints that have the given property value.

Returns {:ok, codepoint_list} for the given property value or an error indication if the property value is not known.

Returns the list of codepoint ranges for the given property value or nil if the property value is not known.

Types

codepoint_list()

@type codepoint_list() :: [codepoint_tuple(), ...]

codepoint_tuple()

@type codepoint_tuple() :: {pos_integer(), pos_integer()}

property()

@type property() :: String.t() | atom() | pos_integer()

Callbacks

aliases()

@callback aliases() :: map()

Returns a map of aliases for the property values served by the implementing module.

count(property)

@callback count(property()) :: pos_integer()

Returns the number of codepoints that have the given property value.

fetch(property)

@callback fetch(property()) :: {:ok, codepoint_list()} | nil

Returns {:ok, codepoint_list} for the given property value or an error indication if the property value is not known.

Property value aliases are resolved.

get(property)

@callback get(property()) :: codepoint_list() | nil

Returns the list of codepoint ranges for the given property value or nil if the property value is not known.

Property value aliases are resolved.