Skip to main content

mig_assembly/
cursor.rs

1//! Segment cursor for tracking position during MIG-guided assembly.
2//!
3//! The core types live in `mig-types::cursor` — re-exported here for
4//! backward compatibility so existing `use crate::cursor::*` paths work.
5
6pub use mig_types::cursor::{consume, expect_segment, peek_is, SegmentCursor, SegmentNotFound};
7
8/// Wrapper version of `expect_segment` that returns `AssemblyError` instead of `SegmentNotFound`.
9///
10/// This provides backward-compatible error types for callers that work with `AssemblyError`.
11pub fn expect_segment_assembly<'a>(
12    segments: &'a [mig_types::segment::OwnedSegment],
13    cursor: &mut SegmentCursor,
14    tag: &str,
15) -> Result<&'a mig_types::segment::OwnedSegment, crate::AssemblyError> {
16    expect_segment(segments, cursor, tag).map_err(|e| e.into())
17}