rustsim-spaces 0.0.1

Space implementations (grid, continuous, graph, hybrid) for rustsim
Documentation
//! No-op space for non-spatial models.
//!
//! [`NothingSpace`] is the simplest space - agents have no position and all
//! spatial operations are no-ops. Use this when your simulation has no
//! spatial structure (e.g. well-mixed population models).
//!
//! Mirrors Julia Agents.jl `nothing` space.

use rustsim_core::interaction::{PositionedAgent, SpaceInteraction};
use rustsim_core::space::Space;

/// A no-op space for non-spatial models.
///
/// Agents using `NothingSpace` must have `Position = ()`. All spatial methods
/// (add, remove, nearby) are trivial no-ops that return empty results.
#[derive(Debug, Default, Clone, Copy)]
pub struct NothingSpace;

impl Space for NothingSpace {}

impl<A> SpaceInteraction<A> for NothingSpace
where
    A: PositionedAgent<Position = ()>,
{
    type Error = std::convert::Infallible;

    fn random_position<R: rand::RngCore>(&self, _rng: &mut R) -> A::Position {}

    fn add_agent(&mut self, _agent: &A) -> Result<(), Self::Error> {
        Ok(())
    }

    fn remove_agent(&mut self, _agent: &A) -> Result<(), Self::Error> {
        Ok(())
    }

    fn nearby_ids(
        &self,
        _position: &A::Position,
        _radius: usize,
    ) -> Vec<rustsim_core::types::AgentId> {
        Vec::new()
    }
}