FromChannelMessage

Trait FromChannelMessage 

Source
pub trait FromChannelMessage: Sized {
    // Required method
    unsafe fn from_channel_message(
        data: *const u8,
        size: usize,
    ) -> Result<Self, String>;
}
Expand description

Represents a type which can be converted to from a channel message sent by a guest plugin. Used by the channel_recv macro.

§Supported Types

  • &[u8] - gives you the raw bytes
  • Vec<u8> - gives you the raw bytes, but owned
  • &str - gives you the bytes as a UTF-8 string. Prints a warning if invalid unicode and skips your callback.
  • String - same as &str but owned
  • Option<T> - rather than print a warning if the type can’t be decoded, pass None
  • Result<T, String> - rather than print out the warning to stdout, pass the warning as a String

Required Methods§

Source

unsafe fn from_channel_message( data: *const u8, size: usize, ) -> Result<Self, String>

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl FromChannelMessage for String

Source§

unsafe fn from_channel_message( data: *const u8, size: usize, ) -> Result<Self, String>

Source§

impl FromChannelMessage for Vec<u8>

Source§

unsafe fn from_channel_message( data: *const u8, size: usize, ) -> Result<Self, String>

Source§

impl<'a> FromChannelMessage for &'a str

Source§

unsafe fn from_channel_message( data: *const u8, size: usize, ) -> Result<Self, String>

Source§

impl<'a> FromChannelMessage for &'a [u8]

Source§

unsafe fn from_channel_message( data: *const u8, size: usize, ) -> Result<Self, String>

Source§

impl<T: FromChannelMessage> FromChannelMessage for Option<T>

Source§

unsafe fn from_channel_message( data: *const u8, size: usize, ) -> Result<Self, String>

Source§

impl<T: FromChannelMessage> FromChannelMessage for Result<T, String>

Source§

unsafe fn from_channel_message( data: *const u8, size: usize, ) -> Result<Self, String>

Implementors§