pub struct LinkFormatWrite<'a, T: ?Sized> { /* private fields */ }
Expand description
Helper for writing IETF-RFC6690 CoAP link-formats to anything implementing
core::fmt::Write
.
§Example
use async_coap::prelude::*;
use async_coap::LinkFormatWrite;
use async_coap::LINK_ATTR_INTERFACE_DESCRIPTION;
// String implements core::fmt::Write
let mut buffer = String::new();
let mut write = LinkFormatWrite::new(&mut buffer);
write.link(uri_ref!("/sensor/light"))
.attr_quoted(LINK_ATTR_INTERFACE_DESCRIPTION,"sensor")
.finish()
.expect("Error writing link");
assert_eq!(&buffer, r#"</sensor/light>;if="sensor""#);
Implementations§
Source§impl<'a, T: Write + ?Sized> LinkFormatWrite<'a, T>
impl<'a, T: Write + ?Sized> LinkFormatWrite<'a, T>
Sourcepub fn new(write: &'a mut T) -> LinkFormatWrite<'a, T>
pub fn new(write: &'a mut T) -> LinkFormatWrite<'a, T>
Creates a new instance of LinkFormatWriter
for a given instance that implements
core::fmt::Write
.
Sourcepub fn set_add_newlines(&mut self, add_newlines: bool)
pub fn set_add_newlines(&mut self, add_newlines: bool)
Sets whether newlines should be added or not between links, possibly improving human readability an the expense of a few extra bytes.
Sourcepub fn link<'b, U: AnyUriRef + ?Sized>(
&'b mut self,
link: &U,
) -> LinkAttributeWrite<'a, 'b, T>
pub fn link<'b, U: AnyUriRef + ?Sized>( &'b mut self, link: &U, ) -> LinkAttributeWrite<'a, 'b, T>
Adds a link to the link format and returns LinkAttributeWrite
.
The returned LinkAttributeWrite
instance can then be used to associate
attributes to the link.
Trait Implementations§
Auto Trait Implementations§
impl<'a, T> Freeze for LinkFormatWrite<'a, T>where
T: ?Sized,
impl<'a, T> RefUnwindSafe for LinkFormatWrite<'a, T>where
T: RefUnwindSafe + ?Sized,
impl<'a, T> Send for LinkFormatWrite<'a, T>
impl<'a, T> Sync for LinkFormatWrite<'a, T>
impl<'a, T> Unpin for LinkFormatWrite<'a, T>where
T: ?Sized,
impl<'a, T> !UnwindSafe for LinkFormatWrite<'a, T>
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