pub struct DM<'a> {
pub channel: &'a mut Channel,
}
Expand description
A struct that provides an interface for interacting with Urbit DMs
Fields§
§channel: &'a mut Channel
Implementations§
Source§impl<'a> DM<'a>
impl<'a> DM<'a>
Sourcepub fn ship_to_dm_name(&self, ship: &str) -> String
pub fn ship_to_dm_name(&self, ship: &str) -> String
Converts a ship @p to the dm_name
string format used for DM channels
Sourcepub fn send_dm_message(
&mut self,
dm_ship: &str,
dm_name: &str,
message: &Message,
) -> Result<String>
pub fn send_dm_message( &mut self, dm_ship: &str, dm_name: &str, message: &Message, ) -> Result<String>
Send a message to an Urbit DM chat. Returns the index of the node that was added to Graph Store.
Sourcepub fn export_dm_log(
&mut self,
dm_ship: &str,
dm_name: &str,
) -> Result<Vec<String>>
pub fn export_dm_log( &mut self, dm_ship: &str, dm_name: &str, ) -> Result<Vec<String>>
Extracts DM chat log automatically into a list of formatted String
s
Extracts a DM chat’s messages as AuthoredMessage
s
Sourcepub fn subscribe_to_dm(
&mut self,
dm_ship: &str,
dm_name: &str,
) -> Result<Receiver<AuthoredMessage>>
pub fn subscribe_to_dm( &mut self, dm_ship: &str, dm_name: &str, ) -> Result<Receiver<AuthoredMessage>>
Subscribe to and watch for messages. This method returns a Receiver
with the
AuthoredMessage
s that are posted after subscribing. Simply call receiver.try_recv()
to read the next AuthoredMessage
if one has been posted.
Technical Note: This method actually creates a new Channel
with your Urbit Ship, and spawns a new unix thread
locally that processes all messages on said channel. This is required due to borrowing mechanisms in Rust, however
on the plus side this makes it potentially more performant by each subscription having it’s own unix thread.
Trait Implementations§
Source§impl<'a> Messaging for DM<'a>
impl<'a> Messaging for DM<'a>
Source§fn send_message(
&mut self,
resource_ship: &str,
resource_name: &str,
message: &Message,
) -> Result<String>
fn send_message( &mut self, resource_ship: &str, resource_name: &str, message: &Message, ) -> Result<String>
Source§fn export_message_log(
&mut self,
resource_ship: &str,
resource_name: &str,
) -> Result<Vec<String>>
fn export_message_log( &mut self, resource_ship: &str, resource_name: &str, ) -> Result<Vec<String>>
String
sAuthoredMessage
sSource§fn export_message_nodes(
&mut self,
resource_ship: &str,
resource_name: &str,
) -> Result<Vec<Node>>
fn export_message_nodes( &mut self, resource_ship: &str, resource_name: &str, ) -> Result<Vec<Node>>
Source§fn subscribe_to_messages(
&mut self,
resource_ship: &str,
resource_name: &str,
) -> Result<Receiver<AuthoredMessage>>
fn subscribe_to_messages( &mut self, resource_ship: &str, resource_name: &str, ) -> Result<Receiver<AuthoredMessage>>
Receiver
with the
AuthoredMessage
s that are posted after subscribing. Simply call receiver.try_recv()
to read the next AuthoredMessage
if one has been posted. Read more