Skip to main content

AstrsMessage

Trait AstrsMessage 

Source
pub trait AstrsMessage: Sized {
    const URN: &'static str;

    // Required methods
    fn data_type() -> DataType;
    fn to_record_batch(&self) -> Result<RecordBatch, DataError>;
    fn from_record_batch(batch: &RecordBatch) -> Result<Self, DataError>;

    // Provided methods
    fn schema() -> Schema { ... }
    fn type_urn() -> Result<TypeUrn, TypeUrnError> { ... }
}
Expand description

A Rust type that maps onto a single-column AstRS payload (blueprint §6.1, §9.2).

See the module documentation for why this trait lives in astrs-data and what it deliberately leaves to callers.

Required Associated Constants§

Source

const URN: &'static str

The type URN this message’s columnar layout is declared against (blueprint §24.3), e.g. "std/vision/v1/Detections".

Required Methods§

Source

fn data_type() -> DataType

The columnar layout AstrsMessage::to_record_batch produces and AstrsMessage::from_record_batch expects.

Source

fn to_record_batch(&self) -> Result<RecordBatch, DataError>

Encodes one message into a one-row RecordBatch (blueprint §6.1’s “one record batch per message”).

§Errors

A crate::DataError from whichever columnar constructor rejects the value. Practically unreachable for a #[derive(AstrsMessage)] impl, since the derive only emits calls that cannot disagree with its own AstrsMessage::data_type, but the trait stays fallible for hand-written implementors.

Source

fn from_record_batch(batch: &RecordBatch) -> Result<Self, DataError>

Decodes one message from a one-row RecordBatch.

§Errors

crate::DataError::MessageRowCount when batch does not hold exactly one row, or another crate::DataError when a column’s shape or nullability disagrees with AstrsMessage::data_type.

Provided Methods§

Source

fn schema() -> Schema

The single-column Schema wrapping AstrsMessage::data_type under crate::DATA_COLUMN (blueprint §6.1).

Source

fn type_urn() -> Result<TypeUrn, TypeUrnError>

Parses AstrsMessage::URN.

§Errors

Whatever TypeUrn::parse reports, wrapped through crate::DataError::TypeUrn. A malformed constant is a programmer error rather than a data error, but the parse is still fallible at the type level — a #[derive(AstrsMessage)] impl’s constant has already passed the macro’s own syntax check (see astrs-operator-macros), so this should only ever fail for a hand-written implementation.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl AstrsMessage for Accel

Source§

const URN: &'static str = "std/geometry/v1/Accel"

Source§

impl AstrsMessage for Bytes

Source§

const URN: &'static str = "std/core/v1/Bytes"

Source§

impl AstrsMessage for BytesRun

Source§

const URN: &'static str = "std/core/v1/Bytes"

Source§

impl AstrsMessage for CompressedImage

Source§

const URN: &'static str = "std/media/v1/CompressedImage"

Source§

impl AstrsMessage for Detections

Source§

const URN: &'static str = "std/vision/v1/Detections"

Source§

impl AstrsMessage for Duration

Source§

const URN: &'static str = "std/time/v1/Duration"

Source§

impl AstrsMessage for Empty

Source§

const URN: &'static str = "std/core/v1/Empty"

Source§

impl AstrsMessage for Flag

Source§

const URN: &'static str = "std/core/v1/Bool"

Source§

impl AstrsMessage for FlagRun

Source§

const URN: &'static str = "std/core/v1/Bool"

Source§

impl AstrsMessage for Imu

Source§

const URN: &'static str = "std/sensor/v1/Imu"

Source§

impl AstrsMessage for Keypoints

Source§

const URN: &'static str = "std/vision/v1/Keypoints"

Source§

impl AstrsMessage for LaserScan

Source§

const URN: &'static str = "std/sensor/v1/LaserScan"

Source§

impl AstrsMessage for Mask

Source§

const URN: &'static str = "std/vision/v1/Mask"

Source§

impl AstrsMessage for NavSatFix

Source§

const URN: &'static str = "std/sensor/v1/NavSatFix"

Source§

impl AstrsMessage for OccupancyGrid

Source§

const URN: &'static str = "std/nav/v1/OccupancyGrid"

Source§

impl AstrsMessage for Odometry

Source§

const URN: &'static str = "std/nav/v1/Odometry"

Source§

impl AstrsMessage for Path

Source§

const URN: &'static str = "std/nav/v1/Path"

Source§

impl AstrsMessage for Pose

Source§

const URN: &'static str = "std/geometry/v1/Pose"

Source§

impl AstrsMessage for Quaternion

Source§

const URN: &'static str = "std/geometry/v1/Quaternion"

Source§

impl AstrsMessage for Range

Source§

const URN: &'static str = "std/sensor/v1/Range"

Source§

impl AstrsMessage for Text

Source§

const URN: &'static str = "std/core/v1/String"

Source§

impl AstrsMessage for TextRun

Source§

const URN: &'static str = "std/core/v1/String"

Source§

impl AstrsMessage for Timestamp

Source§

const URN: &'static str = "std/time/v1/Timestamp"

Source§

impl AstrsMessage for TimestampRun

Source§

const URN: &'static str = "std/time/v1/Timestamp"

Source§

impl AstrsMessage for Transform

Source§

const URN: &'static str = "std/geometry/v1/Transform"

Source§

impl AstrsMessage for Twist

Source§

const URN: &'static str = "std/geometry/v1/Twist"

Source§

impl AstrsMessage for Vector3

Source§

const URN: &'static str = "std/geometry/v1/Vector3"

Source§

impl<T: ScalarType> AstrsMessage for Scalar<T>

Source§

const URN: &'static str = T::SCALAR_URN

Source§

impl<T: ScalarType> AstrsMessage for ScalarRun<T>

Source§

const URN: &'static str = T::SCALAR_URN