macula_mri (macula v0.20.3)
View SourceMacula Resource Identifier (MRI) - Core Module
Provides parsing, validation, formatting, and manipulation of MRIs. MRI format: mri:{type}:{realm}/{path}
Example: {ok, Parsed} = macula_mri:parse(MRI), app = macula_mri:type(Parsed), Realm = macula_mri:realm(Parsed), Path = macula_mri:path(Parsed).
Summary
Functions
Get all ancestors of an MRI, from immediate parent to root.
Append a segment to an MRI's path.
Get the depth of an MRI (0 for realm, 1 for org, etc).
Format an MRI map back to binary.
Check if PotentialAncestor is an ancestor of MRI.
Check if an MRI is valid.
Join path segments with slashes.
Create a new MRI from a map.
Create a new MRI from type, realm, and path.
Create an app MRI.
Create an org MRI.
Create a realm MRI.
Create a service MRI.
Create a user MRI.
Get the parent MRI, or undefined for realm-level MRIs.
Get the parent type for a given type.
Parse an MRI binary into a map.
Get the path segments from an MRI.
Get the path as a single joined string.
Get the realm from an MRI.
Split a path string into segments.
Get the type from an MRI (binary or parsed).
Validate an MRI, returning ok or error with reason.
Types
Functions
Get all ancestors of an MRI, from immediate parent to root.
-spec append_segment(mri() | mri_map(), path_segment()) -> mri().
Append a segment to an MRI's path.
-spec depth(mri() | mri_map()) -> non_neg_integer().
Get the depth of an MRI (0 for realm, 1 for org, etc).
Format an MRI map back to binary.
Check if PotentialAncestor is an ancestor of MRI.
Check if an MRI is valid.
-spec join_path([path_segment()]) -> binary().
Join path segments with slashes.
Create a new MRI from a map.
-spec new(mri_type(), realm(), [path_segment()]) -> {ok, mri()} | {error, term()}.
Create a new MRI from type, realm, and path.
Create an app MRI.
Create an org MRI.
Create a realm MRI.
Create a service MRI.
Create a user MRI.
Get the parent MRI, or undefined for realm-level MRIs.
Get the parent type for a given type.
Parse an MRI binary into a map.
-spec path(mri() | mri_map()) -> [path_segment()].
Get the path segments from an MRI.
Get the path as a single joined string.
Get the realm from an MRI.
-spec split_path(binary()) -> [path_segment()].
Split a path string into segments.
Get the type from an MRI (binary or parsed).
Validate an MRI, returning ok or error with reason.