pub struct Lcm { /* private fields */ }Expand description
An LCM instance that handles publishing and subscribing, as well as encoding and decoding messages.
Implementations§
Source§impl Lcm
impl Lcm
Sourcepub fn new() -> Result<Lcm>
pub fn new() -> Result<Lcm>
Creates a new Lcm instance.
use lcm::Lcm;
let mut lcm = Lcm::new().unwrap();Examples found in repository?
More examples
pub fn get_fileno(&self) -> c_int
Sourcepub fn subscribe<M, F>(
&mut self,
channel: &str,
callback: F,
) -> Rc<LcmSubscription>
pub fn subscribe<M, F>( &mut self, channel: &str, callback: F, ) -> Rc<LcmSubscription>
Subscribes a callback to a particular topic.
let mut lcm = Lcm::new().unwrap();
lcm.subscribe("GREETINGS", |name: String| println!("Hello, {}!", name) );Sourcepub fn unsubscribe(&mut self, handler: Rc<LcmSubscription>) -> Result<()>
pub fn unsubscribe(&mut self, handler: Rc<LcmSubscription>) -> Result<()>
Unsubscribes a message handler.
let handler = lcm.subscribe("GREETINGS", handler_function);
// ...
lcm.unsubscribe(handler);Sourcepub fn publish<M>(&mut self, channel: &str, message: &M) -> Result<()>where
M: Message,
pub fn publish<M>(&mut self, channel: &str, message: &M) -> Result<()>where
M: Message,
Publishes a message on the specified channel.
let mut lcm = Lcm::new().unwrap();
lcm.publish("GREETINGS", &"Charles".to_string()).unwrap();Sourcepub fn handle(&mut self) -> Result<()>
pub fn handle(&mut self) -> Result<()>
Waits for and dispatches the next incoming message.
let mut lcm = Lcm::new().unwrap();
lcm.subscribe("POSITION", handler_function);
loop {
lcm.handle().unwrap();
}Sourcepub fn handle_timeout(&mut self, timeout: Duration) -> Result<()>
pub fn handle_timeout(&mut self, timeout: Duration) -> Result<()>
Waits for and dispatches the next incoming message, up to a time limit.
let mut lcm = Lcm::new().unwrap();
lcm.subscribe("POSITION", handler_function);
let wait_dur = Duration::from_millis(100);
loop {
lcm.handle_timeout(Duration::from_millis(1000)).unwrap();
}Sourcepub fn subscription_set_queue_capacity(
&self,
handler: Rc<LcmSubscription>,
num_messages: usize,
)
pub fn subscription_set_queue_capacity( &self, handler: Rc<LcmSubscription>, num_messages: usize, )
Adjusts the maximum number of received messages that can be queued up for a subscription.
The default is 30.
let handler = lcm.subscribe("POSITION", handler_function);
lcm.subscription_set_queue_capacity(handler, 30);Trait Implementations§
Auto Trait Implementations§
impl Freeze for Lcm
impl !RefUnwindSafe for Lcm
impl !Send for Lcm
impl !Sync for Lcm
impl Unpin for Lcm
impl !UnwindSafe for Lcm
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more