pub trait Transportable<M = ()>: 'static {
// Required methods
fn transport_to_bytes(&self) -> Vec<u8> ⓘ;
fn transport_from_bytes(bytes: &[u8]) -> Result<Self, Error<Error>>
where Self: Sized;
}Expand description
A Transportable type can be safely transported from the server to the client, and be used for
hydration. Not all types can sensibly be transported, but many can. This trait makes it possible
to customize how types are transported which helps for non-serializable types like dioxus_core::CapturedError.
By default, all types that implement Serialize and DeserializeOwned are transportable.
You can also implement Transportable for Result<T, dioxus_core::CapturedError> where T is
Serialize and DeserializeOwned to allow transporting results that may contain errors.
Note that transporting a Result<T, dioxus_core::CapturedError> will lose various aspects of the original
dioxus_core::CapturedError such as backtraces and source errors, but will preserve the error message.
Required Methods§
Sourcefn transport_to_bytes(&self) -> Vec<u8> ⓘ
fn transport_to_bytes(&self) -> Vec<u8> ⓘ
Serialize the type to a byte vector for transport