use std::fmt::Debug;
use libcoap_sys::{coap_event_t, coap_session_get_context, coap_session_t};
use crate::context::CoapContext;
use crate::session::CoapSession;
use crate::session::CoapServerSession;
pub trait CoapEventHandler: Debug {
#[allow(unused_variables)]
fn handle_dtls_connected(&mut self, session: &mut CoapSession) {}
#[allow(unused_variables)]
fn handle_dtls_closed(&mut self, session: &mut CoapSession) {}
#[allow(unused_variables)]
fn handle_dtls_renegotiate(&mut self, session: &mut CoapSession) {}
#[allow(unused_variables)]
fn handle_dtls_error(&mut self, session: &mut CoapSession) {}
#[allow(unused_variables)]
fn handle_tcp_connected(&mut self, session: &mut CoapSession) {}
#[allow(unused_variables)]
fn handle_tcp_closed(&mut self, session: &mut CoapSession) {}
#[allow(unused_variables)]
fn handle_tcp_failed(&mut self, session: &mut CoapSession) {}
#[allow(unused_variables)]
fn handle_session_connected(&mut self, session: &mut CoapSession) {}
#[allow(unused_variables)]
fn handle_session_closed(&mut self, session: &mut CoapSession) {}
#[allow(unused_variables)]
fn handle_session_failed(&mut self, session: &mut CoapSession) {}
#[allow(unused_variables)]
fn handle_partial_block(&mut self, session: &mut CoapSession) {}
#[allow(unused_variables)]
fn handle_server_session_new(&mut self, session: &mut CoapServerSession) {}
#[allow(unused_variables)]
fn handle_server_session_del(&mut self, session: &mut CoapServerSession) {}
}
#[allow(improper_ctypes_definitions)]
pub(crate) unsafe extern "C" fn event_handler_callback(raw_session: *mut coap_session_t, event: coap_event_t) -> i32 {
let session: CoapSession = if event == coap_event_t::COAP_EVENT_SERVER_SESSION_NEW {
CoapServerSession::initialize_raw(raw_session).into()
} else {
CoapSession::from_raw(raw_session)
};
let context = CoapContext::from_raw(coap_session_get_context(raw_session));
context.handle_event(session, event);
0
}