//! Stub Shodan mailbox driver capsule.

use kernel::{AppId, AppSlice, Callback, Driver, Grant, ReturnCode, Shared};

#[derive(Default)]
pub struct AppData {
    pub buffer: Option<AppSlice<Shared, u8>>,
}

pub struct Mailbox {
    pub app_data_grant: Grant<AppData>,
}

impl Driver for Mailbox {
    fn subscribe(&self, _: usize, _: Option<Callback>, _: AppId) -> ReturnCode {
        ReturnCode::EINVAL
    }

    fn command(&self, _minor_num: usize, _r2: usize, _r3: usize, _app_id: AppId) -> ReturnCode {
        return ReturnCode::EINVAL;
    }

    fn allow(&self, app_id: AppId, _: usize, slice: Option<AppSlice<Shared, u8>>) -> ReturnCode {
        let _ = self.app_data_grant.enter(app_id, |app_data, _| {
            app_data.buffer = slice;
        });
        return ReturnCode::SUCCESS;
    }
}
