[][src]Struct async_coap::link_format::LinkFormatWrite

pub struct LinkFormatWrite<'a, T: ?Sized> { /* fields omitted */ }

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.

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> Send for LinkFormatWrite<'a, T> where
    T: Send

impl<'a, T: ?Sized> Unpin for LinkFormatWrite<'a, T>

impl<'a, T: ?Sized> Sync for LinkFormatWrite<'a, T> where
    T: Sync

impl<'a, T: ?Sized> RefUnwindSafe for LinkFormatWrite<'a, T> where
    T: RefUnwindSafe

impl<'a, T> !UnwindSafe for LinkFormatWrite<'a, T>

Blanket Implementations

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,