[−][src]Struct async_coap::link_format::LinkFormatWrite
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""#);
Methods
impl<'a, T: Write + ?Sized> LinkFormatWrite<'a, T>
[src]
pub fn new(write: &'a mut T) -> LinkFormatWrite<'a, T>
[src]
Creates a new instance of LinkFormatWriter
for a given instance that implements
core::fmt::Write
.
pub fn set_add_newlines(&mut self, add_newlines: bool)
[src]
Sets whether newlines should be added or not between links, possibly improving human readability an the expense of a few extra bytes.
pub fn link<'b, U: AnyUriRef + ?Sized>(
&'b mut self,
link: &U
) -> LinkAttributeWrite<'a, 'b, T>
[src]
&'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.
pub fn finish(self) -> Result<(), Error>
[src]
Consumes this LinkFormatWrite
instance, returning any error that
might have occurred during writing.
Trait Implementations
impl<'a, T: Debug + ?Sized> Debug for LinkFormatWrite<'a, T>
[src]
Auto Trait Implementations
impl<'a, T: ?Sized> Unpin for LinkFormatWrite<'a, T>
impl<'a, T: ?Sized> Sync for LinkFormatWrite<'a, T> where
T: Sync,
T: Sync,
impl<'a, T: ?Sized> Send for LinkFormatWrite<'a, T> where
T: Send,
T: Send,
impl<'a, T> !UnwindSafe for LinkFormatWrite<'a, T>
impl<'a, T: ?Sized> RefUnwindSafe for LinkFormatWrite<'a, T> where
T: RefUnwindSafe,
T: RefUnwindSafe,
Blanket Implementations
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> From<T> for T
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,