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>
impl<'a> JsonWriter<'a>
Sourcepub fn new<T: Write>(writer: &'a mut T) -> JsonWriter<'a>
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>
impl<'a> FormatWriter for JsonWriter<'a>
Source§fn write_changelog(&mut self, options: &Clog, sm: &SectionMap) -> Result<()>
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 sortsAuto 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> 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