objets_metier_rs 1.0.2

Bibliothèque Rust moderne et sûre pour l'API COM Objets Métier Sage 100c - Production Ready
// DocumentInterne - Documents internes
use crate::com::{SafeDispatch, SafeVariant};
use crate::errors::SageResult;
use windows::Win32::System::Com::IDispatch;

pub struct DocumentInterne {
    pub(crate) dispatch: IDispatch,
}

impl DocumentInterne {
    fn dispatch(&self) -> SafeDispatch<'_> {
        SafeDispatch::new(&self.dispatch)
    }

    pub fn do_piece(&self) -> SageResult<String> {
        self.dispatch()
            .call_method_by_name("DO_Piece", &[])?
            .to_string()
    }

    pub fn set_do_piece(&self, value: &str) -> SageResult<()> {
        let param = SafeVariant::from_string(value);
        self.dispatch().call_property_put("DO_Piece", &[param])?;
        Ok(())
    }

    pub fn do_type(&self) -> SageResult<i32> {
        self.dispatch()
            .call_method_by_name("DO_Type", &[])?
            .to_i32()
    }

    pub fn cbmarq(&self) -> SageResult<i32> {
        self.dispatch().call_method_by_name("cbMarq", &[])?.to_i32()
    }

    pub fn write(&self) -> SageResult<()> {
        self.dispatch().call_method_by_name("Write", &[])?;
        Ok(())
    }

    pub fn remove(&self) -> SageResult<()> {
        self.dispatch().call_method_by_name("Remove", &[])?;
        Ok(())
    }
}