Skip to main content

Join

Struct Join 

Source
pub struct Join<O: TextOut> { /* private fields */ }
Expand description

Writes a separator between logical items.

An item is what lies between Join::item_start and Join::item_end; it may be written in any number of fragments, or in none, and an empty item is still an item, so ["", ""] joined with , is ,. A fragment written outside an item is an item of its own, which is the common case of one text per element and needs no markers. The separator goes before every item but the first, never between the fragments of one item: that distinction is the whole reason this type exists, because a chunked transport must not change the text.

Implementations§

Source§

impl<O: TextOut> Join<O>

Source

pub fn new(out: O, separator: impl Into<Box<str>>) -> Self

Source

pub fn item_start(&mut self) -> Result<(), Fail>

Begin an item: the separator is written now if an item came before. Starting an item inside an item is PROTOCOL_ORDER_ERROR.

Source

pub fn item_end(&mut self) -> Result<(), Fail>

End the current item. Ending when no item is open is PROTOCOL_ORDER_ERROR.

Source

pub fn items(&self) -> u64

Items begun so far.

Source

pub fn into_inner(self) -> O

Trait Implementations§

Source§

impl<O: TextOut> TextOut for Join<O>

Source§

fn flush(&mut self) -> Result<(), Fail>

Flushes the output beneath; an open item stays open, since a flush is about transport and an item is about meaning.

Source§

fn write_str(&mut self, s: &str) -> Result<(), Fail>

Source§

fn has_committed(&self) -> bool

Whether any text has reached the final destination, so that a failure found now leaves partial output behind. A renderer asks this when it fails and reports committed_output from the answer, which is how a host knows to print output: "partial" rather than "none". The default is the conservative answer for an output that cannot tell: whatever the renderer handed over may be out. WriteOut answers exactly, from the bytes its writer received; a fragment that is still buffered is not committed, and into_inner drops it rather than sending it after the fact.

Auto Trait Implementations§

§

impl<O> Freeze for Join<O>
where O: Freeze,

§

impl<O> RefUnwindSafe for Join<O>
where O: RefUnwindSafe,

§

impl<O> Send for Join<O>
where O: Send,

§

impl<O> Sync for Join<O>
where O: Sync,

§

impl<O> Unpin for Join<O>
where O: Unpin,

§

impl<O> UnsafeUnpin for Join<O>
where O: UnsafeUnpin,

§

impl<O> UnwindSafe for Join<O>
where O: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.