mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-17 08:40:52 +00:00
fail, don't panic on serialization failure
this allows us to handle the error. probably should propagate on to xous-ipc
This commit is contained in:
parent
8cd1cef679
commit
2e9b19d62d
1 changed files with 8 additions and 5 deletions
|
|
@ -404,7 +404,7 @@ use num_traits::*;
|
||||||
use rkyv::{
|
use rkyv::{
|
||||||
Archive, Place, Serialize,
|
Archive, Place, Serialize,
|
||||||
api::low::LowSerializer,
|
api::low::LowSerializer,
|
||||||
rancor::Panic,
|
rancor::Failure,
|
||||||
ser::{Positional, allocator::SubAllocator, writer::Buffer as RkyvBuffer},
|
ser::{Positional, allocator::SubAllocator, writer::Buffer as RkyvBuffer},
|
||||||
with::{ArchiveWith, SerializeWith},
|
with::{ArchiveWith, SerializeWith},
|
||||||
};
|
};
|
||||||
|
|
@ -463,7 +463,7 @@ fn main() -> ! {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// For manual serialization to rkyv in this crate.
|
/// For manual serialization to rkyv in this crate.
|
||||||
type Serializer<'a, 'b> = LowSerializer<RkyvBuffer<'b>, SubAllocator<'a>, Panic>;
|
type Serializer<'a, 'b> = LowSerializer<RkyvBuffer<'b>, SubAllocator<'a>, Failure>;
|
||||||
struct Wrap<'a, F, T>(&'a T, PhantomData<F>);
|
struct Wrap<'a, F, T>(&'a T, PhantomData<F>);
|
||||||
|
|
||||||
impl<F, T> Archive for Wrap<'_, F, T>
|
impl<F, T> Archive for Wrap<'_, F, T>
|
||||||
|
|
@ -482,7 +482,10 @@ impl<'a, 'b, F, T> Serialize<Serializer<'a, 'b>> for Wrap<'_, F, T>
|
||||||
where
|
where
|
||||||
F: SerializeWith<T, Serializer<'a, 'b>>,
|
F: SerializeWith<T, Serializer<'a, 'b>>,
|
||||||
{
|
{
|
||||||
fn serialize(&self, serializer: &mut Serializer<'a, 'b>) -> core::result::Result<Self::Resolver, Panic> {
|
fn serialize(
|
||||||
|
&self,
|
||||||
|
serializer: &mut Serializer<'a, 'b>,
|
||||||
|
) -> core::result::Result<Self::Resolver, Failure> {
|
||||||
F::serialize_with(self.0, serializer)
|
F::serialize_with(self.0, serializer)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1914,7 +1917,7 @@ fn wrapped_main() -> ! {
|
||||||
let wrap = Wrap(&rec, PhantomData::<Identity>);
|
let wrap = Wrap(&rec, PhantomData::<Identity>);
|
||||||
let writer = RkyvBuffer::from(&mut *sbuf);
|
let writer = RkyvBuffer::from(&mut *sbuf);
|
||||||
let alloc = SubAllocator::new(&mut scratch);
|
let alloc = SubAllocator::new(&mut scratch);
|
||||||
match rkyv::api::low::to_bytes_in_with_alloc::<_, _, Panic>(
|
match rkyv::api::low::to_bytes_in_with_alloc::<_, _, Failure>(
|
||||||
&wrap, writer, alloc,
|
&wrap, writer, alloc,
|
||||||
) {
|
) {
|
||||||
Ok(serbuf) => {
|
Ok(serbuf) => {
|
||||||
|
|
@ -1950,7 +1953,7 @@ fn wrapped_main() -> ! {
|
||||||
let wrap = Wrap(&rec, PhantomData::<Identity>);
|
let wrap = Wrap(&rec, PhantomData::<Identity>);
|
||||||
let writer = RkyvBuffer::from(&mut *buf);
|
let writer = RkyvBuffer::from(&mut *buf);
|
||||||
let alloc = SubAllocator::new(&mut scratch);
|
let alloc = SubAllocator::new(&mut scratch);
|
||||||
match rkyv::api::low::to_bytes_in_with_alloc::<_, _, Panic>(
|
match rkyv::api::low::to_bytes_in_with_alloc::<_, _, Failure>(
|
||||||
&wrap, writer, alloc,
|
&wrap, writer, alloc,
|
||||||
) {
|
) {
|
||||||
Ok(serbuf) => {
|
Ok(serbuf) => {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue