INNER CODE UNIT · Rust

encode_message

nativeshell/nativeshell · nativeshell/src/codec/mod.rs:69

    fn encode_message(&self, v: &V) -> Vec<u8>;
    fn decode_message(&self, buf: &[u8]) -> Option<V>;
}

pub trait MethodCodec<V>: Send + Sync {
    fn decode_method_call(&self, buf: &[u8]) -> Option<MethodCall<V>>;
    fn encode_success_envelope(&self, v: &V) -> Vec<u8>;
    fn encode_error_envelope(&self, code: &str, message: Option<&str>, details: &V) -> Vec<u8>;

    fn encode_method_call_result(&self, response: &MethodCallResult<V>) -> Vec<u8> {
        match response {
            MethodCallResult::Ok(data) => self.encode_success_envelope(data),
            MethodCallResult::Err(err) => {
                self.encode_error_envelope(&err.code, err.message.as_deref(), &err.details)
            }
        }
    }

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…