mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2025-08-09 17:32:12 +00:00
20 lines
462 B
Rust
20 lines
462 B
Rust
![]() |
use flowy_derive::ProtoBuf;
|
||
|
use std::convert::TryFrom;
|
||
|
|
||
|
#[derive(Default, ProtoBuf)]
|
||
|
pub struct FFIRequest {
|
||
|
#[pb(index = 1)]
|
||
|
event: String,
|
||
|
|
||
|
#[pb(index = 2)]
|
||
|
payload: Vec<u8>,
|
||
|
}
|
||
|
|
||
|
impl FFIRequest {
|
||
|
pub fn from_u8_pointer(pointer: *const u8, len: usize) -> Self {
|
||
|
let bytes = unsafe { std::slice::from_raw_parts(pointer, len) }.to_vec();
|
||
|
let request: FFIRequest = FFIRequest::try_from(&bytes).unwrap();
|
||
|
request
|
||
|
}
|
||
|
}
|