Skip to main content

Stack

Trait Stack 

Source
pub trait Stack {
    type Point: Copy + Eq + Hash;
    type CapPt: Copy + Eq + Hash;
    type VerticalPayload: Clone;
    type BaseSieve: Sieve<Point = Self::Point>;
    type CapSieve: Sieve<Point = Self::CapPt>;

    // Required methods
    fn lift<'a>(
        &'a self,
        p: Self::Point,
    ) -> Box<dyn Iterator<Item = (Self::CapPt, Self::VerticalPayload)> + 'a>;
    fn drop<'a>(
        &'a self,
        q: Self::CapPt,
    ) -> Box<dyn Iterator<Item = (Self::Point, Self::VerticalPayload)> + 'a>;
    fn add_arrow(
        &mut self,
        base: Self::Point,
        cap: Self::CapPt,
        pay: Self::VerticalPayload,
    ) -> Result<(), MeshSieveError>;
    fn remove_arrow(
        &mut self,
        base: Self::Point,
        cap: Self::CapPt,
    ) -> Result<Option<Self::VerticalPayload>, MeshSieveError>;
    fn base(&self) -> &Self::BaseSieve;
    fn cap(&self) -> &Self::CapSieve;
    fn base_mut(&mut self) -> Result<&mut Self::BaseSieve, MeshSieveError>;
    fn cap_mut(&mut self) -> Result<&mut Self::CapSieve, MeshSieveError>;
}
Expand description

A Stack links a base Sieve to a cap Sieve via vertical arrows. Each vertical arrow carries its own payload (e.g., polarity or permutation), independent of the horizontal Sieve payloads.

  • Point: The point type in the base mesh (commonly PointId).
  • CapPt: The point type in the cap mesh (commonly PointId).
  • VerticalPayload: Data attached to each vertical arrow (e.g., Polarity).

Some implementations (such as ComposedStack) do not expose a concrete base or cap Sieve. Calling Stack::base or Stack::cap on such stacks will panic. A future refactor may return Option or Result to make these unsupported operations explicit.

Required Associated Types§

Source

type Point: Copy + Eq + Hash

Base mesh point identifier.

Source

type CapPt: Copy + Eq + Hash

Cap mesh point identifier.

Source

type VerticalPayload: Clone

Vertical arrow payload type.

Source

type BaseSieve: Sieve<Point = Self::Point>

Underlying base Sieve type (horizontal), payload unconstrained.

Source

type CapSieve: Sieve<Point = Self::CapPt>

Underlying cap Sieve type (horizontal), payload unconstrained.

Required Methods§

Source

fn lift<'a>( &'a self, p: Self::Point, ) -> Box<dyn Iterator<Item = (Self::CapPt, Self::VerticalPayload)> + 'a>

Returns an iterator over all upward arrows from base point p to cap points. Each item is (cap_point, vertical_payload).

Source

fn drop<'a>( &'a self, q: Self::CapPt, ) -> Box<dyn Iterator<Item = (Self::Point, Self::VerticalPayload)> + 'a>

Returns an iterator over all downward arrows from cap point q to base points. Each item is (base_point, vertical_payload).

Source

fn add_arrow( &mut self, base: Self::Point, cap: Self::CapPt, pay: Self::VerticalPayload, ) -> Result<(), MeshSieveError>

Adds a new vertical arrow base -> cap with associated payload.

Source

fn remove_arrow( &mut self, base: Self::Point, cap: Self::CapPt, ) -> Result<Option<Self::VerticalPayload>, MeshSieveError>

Removes the arrow base -> cap, returning its payload if present.

Source

fn base(&self) -> &Self::BaseSieve

Returns a reference to the underlying base Sieve.

§Panics

Implementations may panic if the base Sieve is not exposed (e.g., ComposedStack).

Source

fn cap(&self) -> &Self::CapSieve

Returns a reference to the underlying cap Sieve.

§Panics

Implementations may panic if the cap Sieve is not exposed (e.g., ComposedStack).

Source

fn base_mut(&mut self) -> Result<&mut Self::BaseSieve, MeshSieveError>

Returns a mutable reference to the underlying base Sieve.

Source

fn cap_mut(&mut self) -> Result<&mut Self::CapSieve, MeshSieveError>

Returns a mutable reference to the underlying cap Sieve.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§

Source§

impl<'a, S1, S2, F, VO> Stack for ComposedStack<'a, S1, S2, F, VO>
where S1: Stack, S2: Stack<Point = S1::CapPt>, F: Fn(&S1::VerticalPayload, &S2::VerticalPayload) -> VO + Sync + Send, VO: Clone,

Source§

impl<B, C, V, PB, PC> Stack for InMemoryStack<B, C, V, PB, PC>