You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A possible common use case could be serializing a complex value instead of using Uniffi for everything like a structured record like a JSON type. For example I'd expect to be able to have a failure when lowering:
/// Serialize the given data structure as a String of JSON.////// # Errors////// Serialization can fail if `T`'s implementation of `Serialize` decides to/// fail, or if `T` contains a map with non-string keys.#[inline]pubfnto_string<T>(value:&T) -> Result<String>whereT: ?Sized + Serialize,{let vec = tri!(to_vec(value));let string = unsafe{// We do not emit invalid UTF-8.String::from_utf8_unchecked(vec)};Ok(string)}
The text was updated successfully, but these errors were encountered:
I agree with this. The current system is based on the general lift/lower system, where we assume that any Rust type can be lowered and the only error possibility is when lifting data from the other side of the FFI. This is usually true, but not always.
I feel like I remember some corner cases with callback interfaces that are related to this as well, but I'm coming up blank when trying to recall them.
A possible common use case could be serializing a complex value instead of using Uniffi for everything like a structured record like a JSON type. For example I'd expect to be able to have a failure when lowering:
I assumed that was possible, but found out only
lower
that doesn't return an error is available. A generic structure like aserde_json::Value
may be invalid if non-string keys are used:The text was updated successfully, but these errors were encountered: