Struct safe_drive::topic::publisher::Publisher
source · pub struct Publisher<T> { /* private fields */ }
Expand description
Publisher.
§Example
use safe_drive::{context::Context, msg::common_interfaces::std_msgs};
let ctx = Context::new().unwrap();
let node_pub = ctx
.create_node("publish_rs", None, Default::default())
.unwrap();
// Create a publisher.
let publisher = node_pub
.create_publisher::<std_msgs::msg::UInt32>("publish_rs_topic", None,
).unwrap();
// Send a message.
let mut msg = std_msgs::msg::UInt32::new().unwrap();
msg.data = 1234;
publisher.send(&msg).unwrap();
Implementations§
source§impl<T: TypeSupport> Publisher<T>
impl<T: TypeSupport> Publisher<T>
pub fn get_topic_name(&self) -> &str
pub fn can_loan_messages(&self) -> bool
sourcepub fn borrow_loaned_message(&self) -> RCLResult<PublisherLoanedMessage<T>>
pub fn borrow_loaned_message(&self) -> RCLResult<PublisherLoanedMessage<T>>
Borrows a memory chunk from the shared memory.
sourcepub fn send(&self, msg: &T) -> Result<(), DynError>
pub fn send(&self, msg: &T) -> Result<(), DynError>
Send a message.
§Example
use safe_drive::{context::Context, msg::common_interfaces::std_msgs};
let ctx = Context::new().unwrap();
let node = ctx
.create_node("publish_rs_send", None, Default::default())
.unwrap();
// Create a publisher.
let publisher = node.create_publisher("publish_rs_send_topic", None).unwrap();
// Send a message.
let msg = std_msgs::msg::Empty::new().unwrap();
publisher.send(&msg).unwrap();
§Errors
RCLError::InvalidArgument
if any arguments are invalid, orRCLError::PublisherInvalid
if the publisher is invalid, orRCLError::Error
if an unspecified error occurs.
sourcepub fn send_loaned(
&self,
msg: PublisherLoanedMessage<T>
) -> Result<(), DynError>
pub fn send_loaned( &self, msg: PublisherLoanedMessage<T> ) -> Result<(), DynError>
Send a loaned message.
This functions takes the ownership of the loaned message since its chunk should be transferred back to the middleware.
Trait Implementations§
impl<T> Send for Publisher<T>
impl<T> Sync for Publisher<T>
Auto Trait Implementations§
impl<T> Freeze for Publisher<T>
impl<T> RefUnwindSafe for Publisher<T>where
T: RefUnwindSafe,
impl<T> Unpin for Publisher<T>where
T: Unpin,
impl<T> UnwindSafe for Publisher<T>where
T: UnwindSafe,
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