mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-16 08:38:26 +00:00
clean up API even further
This commit is contained in:
parent
c259d5566d
commit
3120b5d13c
3 changed files with 7 additions and 8 deletions
|
|
@ -66,7 +66,7 @@ pub fn send_message(connection: CID, mut message: Message) -> core::result::Resu
|
|||
// emulated TextView
|
||||
let mut buffer =
|
||||
unsafe { Buffer::from_memory_message_mut(msg.body.memory_message_mut().unwrap()) };
|
||||
let mut tv = buffer.to_original::<crate::testcases::TextView, _, rkyv::rancor::Error>().unwrap();
|
||||
let mut tv = buffer.to_original::<crate::testcases::TextView, _>().unwrap();
|
||||
|
||||
println!("MSG: TextView");
|
||||
println!("Contents: {:?}", tv);
|
||||
|
|
@ -218,15 +218,14 @@ impl<'buf> Buffer<'buf> {
|
|||
self.replace_inner::<Identity, T>(src)
|
||||
}
|
||||
|
||||
pub fn to_original<T, U, E>(&self) -> core::result::Result<T, E>
|
||||
pub fn to_original<T, U>(&self) -> core::result::Result<T, ()>
|
||||
where
|
||||
T: rkyv::Archive<Archived = U>,
|
||||
U: Portable,
|
||||
E: std::fmt::Debug,
|
||||
<T as Archive>::Archived: Deserialize<T, Strategy<rkyv::de::Pool, E>>,
|
||||
<T as Archive>::Archived: Deserialize<T, Strategy<rkyv::de::Pool, rkyv::rancor::Error>>,
|
||||
{
|
||||
let r = unsafe { rkyv::access_unchecked::<U>(&self.slice[..self.used]) };
|
||||
Ok(rkyv::deserialize::<T, E>(r).unwrap())
|
||||
Ok(rkyv::deserialize::<T, rkyv::rancor::Error>(r).unwrap())
|
||||
}
|
||||
|
||||
pub fn as_flat<T, U>(&self) -> core::result::Result<&U, ()>
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ fn main() {
|
|||
let f = buf.as_flat::<Test, _>().unwrap();
|
||||
println!("f: {:?}", f);
|
||||
|
||||
let t1 = buf.to_original::<Test, _, Error>().unwrap();
|
||||
let t1 = buf.to_original::<Test, _>().unwrap();
|
||||
println!("t copy 1: {:?}", t1);
|
||||
|
||||
println!("buf.slice: {:x?}", &buf[..buf.used()]);
|
||||
|
|
@ -74,7 +74,7 @@ fn main() {
|
|||
match tv_buf.lend_mut(1, 1) {
|
||||
Ok(r) => {
|
||||
println!("Returned {:?}", r);
|
||||
let mut tv_orig = tv_buf.to_original::<TextView, _, Error>().unwrap();
|
||||
let mut tv_orig = tv_buf.to_original::<TextView, _>().unwrap();
|
||||
println!("bounds_computed: {:?}", tv_orig.bounds_computed);
|
||||
assert_eq!(tv_orig.bounds_computed.unwrap().tl.x, 42);
|
||||
assert_eq!(tv_orig.bounds_computed.unwrap().tl.y, 42);
|
||||
|
|
|
|||
|
|
@ -205,7 +205,7 @@ pub fn draw_textview(conn: xous::CID, tv: &mut TextView) -> Result<(), xous::Err
|
|||
let mut buf = crate::Buffer::into_buf(tv);
|
||||
buf.lend_mut(conn, Opcode::DrawTextView.to_u32().unwrap()).or(Err(xous::Error::InternalError))?;
|
||||
|
||||
let tvr = buf.to_original::<TextView, _, rkyv::rancor::Error>().unwrap();
|
||||
let tvr = buf.to_original::<TextView, _>().unwrap();
|
||||
tv.bounds_computed = tvr.bounds_computed;
|
||||
tv.cursor = tvr.cursor;
|
||||
tv.overflow = tvr.overflow;
|
||||
|
|
|
|||
Loading…
Reference in a new issue