BB.Message.Option (bb v0.20.1)

Copy Markdown View Source

Custom Spark.Options types for message primitives.

Provides type functions for use in payload schemas to validate BB.Math.Vec3.t(), BB.Math.Quaternion.t(), and BB.Math.Transform.t() types.

Usage

import BB.Message.Option

@schema Spark.Options.new!([
  position: [type: vec3_type(), required: true],
  orientation: [type: quaternion_type(), required: true],
  pose: [type: transform_type(), required: true]
])

Summary

Functions

Returns a Spark.Options type for validating BB.Math.Covariance3.t().

Returns a Spark.Options type for validating BB.Math.Covariance6.t().

Returns a Spark.Options type for validating BB.Quaternion.t().

Returns a Spark.Options type for validating BB.Math.Transform.t().

Validates a BB.Math.Covariance3 struct.

Validates a BB.Math.Covariance6 struct.

Validates a BB.Quaternion struct.

Validates a BB.Math.Transform struct.

Validates a BB.Vec3 struct.

Returns a Spark.Options type for validating BB.Vec3.t().

Functions

covariance3_type()

@spec covariance3_type() :: {:custom, module(), atom(), list()}

Returns a Spark.Options type for validating BB.Math.Covariance3.t().

Examples

iex> BB.Message.Option.covariance3_type()
{:custom, BB.Message.Option, :validate_covariance3, [[]]}

covariance6_type()

@spec covariance6_type() :: {:custom, module(), atom(), list()}

Returns a Spark.Options type for validating BB.Math.Covariance6.t().

Examples

iex> BB.Message.Option.covariance6_type()
{:custom, BB.Message.Option, :validate_covariance6, [[]]}

quaternion_type()

@spec quaternion_type() :: {:custom, module(), atom(), list()}

Returns a Spark.Options type for validating BB.Quaternion.t().

Examples

iex> BB.Message.Option.quaternion_type()
{:custom, BB.Message.Option, :validate_quaternion, [[]]}

transform_type()

@spec transform_type() :: {:custom, module(), atom(), list()}

Returns a Spark.Options type for validating BB.Math.Transform.t().

Examples

iex> BB.Message.Option.transform_type()
{:custom, BB.Message.Option, :validate_transform, [[]]}

validate_covariance3(cov, opts)

@spec validate_covariance3(
  term(),
  keyword()
) :: {:ok, BB.Math.Covariance3.t()} | {:error, String.t()}

Validates a BB.Math.Covariance3 struct.

validate_covariance6(cov, opts)

@spec validate_covariance6(
  term(),
  keyword()
) :: {:ok, BB.Math.Covariance6.t()} | {:error, String.t()}

Validates a BB.Math.Covariance6 struct.

validate_quaternion(quat, opts)

@spec validate_quaternion(
  term(),
  keyword()
) :: {:ok, BB.Math.Quaternion.t()} | {:error, String.t()}

Validates a BB.Quaternion struct.

Examples

iex> BB.Message.Option.validate_quaternion(BB.Quaternion.identity(), [])
{:ok, %BB.Quaternion{}}

iex> BB.Message.Option.validate_quaternion("not a quaternion", [])
{:error, "expected BB.Quaternion.t(), got: \"not a quaternion\""}

validate_transform(transform, opts)

@spec validate_transform(
  term(),
  keyword()
) :: {:ok, BB.Math.Transform.t()} | {:error, String.t()}

Validates a BB.Math.Transform struct.

Examples

iex> BB.Message.Option.validate_transform(BB.Math.Transform.identity(), [])
{:ok, %BB.Math.Transform{}}

iex> BB.Message.Option.validate_transform("not a transform", [])
{:error, "expected BB.Math.Transform.t(), got: \"not a transform\""}

validate_vec3(vec, opts)

@spec validate_vec3(
  term(),
  keyword()
) :: {:ok, BB.Math.Vec3.t()} | {:error, String.t()}

Validates a BB.Vec3 struct.

Examples

iex> BB.Message.Option.validate_vec3(BB.Vec3.new(1.0, 2.0, 3.0), [])
{:ok, %BB.Vec3{}}

iex> BB.Message.Option.validate_vec3("not a vec3", [])
{:error, "expected BB.Vec3.t(), got: \"not a vec3\""}

vec3_type()

@spec vec3_type() :: {:custom, module(), atom(), list()}

Returns a Spark.Options type for validating BB.Vec3.t().

Examples

iex> BB.Message.Option.vec3_type()
{:custom, BB.Message.Option, :validate_vec3, [[]]}