Add api handle implementation

This commit is contained in:
Jazz Turner-Baggs 2026-02-04 13:30:02 -08:00
parent 3b90c9d58a
commit 6ae32d6b60
No known key found for this signature in database
3 changed files with 21 additions and 10 deletions

View File

@ -148,19 +148,28 @@ pub fn send_content(
pub fn handle_payload(
ctx: &mut ContextHandle,
payload: c_slice::Ref<'_, u8>,
mut conversation_id_out: c_slice::Mut<'_, u8>,
conversation_id_out_len: Out<'_, u32>,
mut content_out: c_slice::Mut<'_, u8>,
) -> HandlePayloadResult {
let content = match ctx.0.handle_payload(&payload) {
Some(v) => v,
None => {
return HandlePayloadResult {
error_code: ErrorCode::UnknownError as i32,
convo_id: "".into(),
content: safer_ffi::Vec::EMPTY,
events: Events::None,
};
}
};
HandlePayloadResult {
error_code: ErrorCode::NotImplemented as i32,
convo_id: "".into(),
content: safer_ffi::Vec::EMPTY,
events: Events::None,
error_code: ErrorCode::None as i32,
convo_id: repr_c::String::from(content.conversation_id),
content: safer_ffi::Vec::from(content.data),
events: if content.isNewConvo {
Events::NewConvo
} else {
Events::None
},
}
}

View File

@ -72,6 +72,7 @@ impl Context {
Some(ContentData {
conversation_id: "convo_id".into(),
data: vec![1, 2, 3, 4, 5, 6],
isNewConvo: false,
})
}

View File

@ -14,6 +14,7 @@ pub struct AddressedEnvelope {
pub struct ContentData {
pub conversation_id: String,
pub data: Vec<u8>,
pub isNewConvo: bool, // This feild indicates that
}
// Internal type Definitions