JsonWriter

Struct JsonWriter 

Source
pub struct JsonWriter<'a>(/* private fields */);
Expand description

Wraps a std::io::Write object to write clog output in a JSON format

§Example

let clog = Clog::new().unwrap();

// Get the commits we're interested in...
let sm = SectionMap::from_commits(clog.get_commits().unwrap());

// Create a file to hold our results, which the JsonWriter will wrap (note, .unwrap() is only
// used to keep the example short and concise)
let mut file = File::create("my_changelog.json").ok().unwrap();

// Create the JSON Writer
let mut writer = JsonWriter::new(&mut file);

// Use the JsonWriter to write the changelog
clog.write_changelog_with(&mut writer).unwrap();

Implementations§

Source§

impl<'a> JsonWriter<'a>

Source

pub fn new<T: Write>(writer: &'a mut T) -> JsonWriter<'a>

Creates a new instance of the JsonWriter struct using a std::io::Write object.

§Example
let clog = Clog::new().unwrap();

// Create a JsonWriter to wrap stdout
let out = stdout();
let mut out_buf = BufWriter::new(out.lock());
let mut writer = JsonWriter::new(&mut out_buf);

Trait Implementations§

Source§

impl<'a> FormatWriter for JsonWriter<'a>

Source§

fn write_changelog(&mut self, options: &Clog, sm: &SectionMap) -> Result<()>

Writes a changelog from a given clog::SectionMap which can be thought of as an “AST” of sorts

Auto Trait Implementations§

§

impl<'a> Freeze for JsonWriter<'a>

§

impl<'a> !RefUnwindSafe for JsonWriter<'a>

§

impl<'a> !Send for JsonWriter<'a>

§

impl<'a> !Sync for JsonWriter<'a>

§

impl<'a> Unpin for JsonWriter<'a>

§

impl<'a> !UnwindSafe for JsonWriter<'a>

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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.