gurobirs 0.0.2

A Rust-API resembling the C++ API of the Gurobi Optimizer.
use std::ffi::CString;

use crate::ffi;
use crate::model::GRBModelSense;
use crate::var::GRBVar;
use crate::{model::GRBModel, prelude::GRBCallbackContext};

pub(crate) trait CanBeAddedToModel {
    /// take out the name, leave a none in place
    fn get_name(&mut self) -> Option<CString>;
    fn add_to_model(self, model: *mut ffi::GRBmodel, name: *const std::ffi::c_char) -> i32;
}

pub(crate) trait AddAsIndicator {
    fn add_as_indicator(
        self,
        model: *mut ffi::GRBmodel,
        binvar: GRBVar,
        binval: i8,
        name: *const std::ffi::c_char,
    ) -> i32;
}

/// Marker trait for modeling objects (variables, constraints, etc)
/// This can then be used to implement generic functions that work with any modeling object
pub trait IsModelingObject {
    fn index(&self) -> usize;
}
// returns i32, because we need access to either a GRBModel or GRBEnv in order to handle errors
pub trait CanBeAddedToCallback {
    fn add_cut(self, callback: &mut GRBCallbackContext) -> i32;
    fn add_lazy(self, callback: &mut GRBCallbackContext) -> i32;
}

pub trait Objective {
    fn set_as_objective(self, model: &mut GRBModel, sense: GRBModelSense);
}

pub mod builder;
pub mod expr;