commit 7e2a962977ba886dfc5bafec2018fda61f1eb5c8
parent 4a49ade12d5ea1a52ae1de26ab5954abf211cb7a
Author: lash <dev@holbrook.no>
Date: Mon, 1 Jul 2024 01:50:37 +0100
Create metadata object that can apply itself to feed
Diffstat:
2 files changed, 12 insertions(+), 3 deletions(-)
diff --git a/src/lib.rs b/src/lib.rs
@@ -58,14 +58,21 @@ impl Sequencer {
c
}
- fn write_to(&self, w: impl Write) -> Result<(), atom_syndication::Error> {
+ fn write_to(&mut self, w: impl Write) -> Result<usize, atom_syndication::Error> {
+ let mut r: usize;
let mut feed = OutFeed::default();
feed.set_id("urn:uuid:60a76c80-d399-11d9-b91C-0003939e0af6");
feed.set_title("Mixed feed");
feed.set_updated(Local::now().to_utc());
self.metadata.apply(&mut feed);
feed.write_to(w)?;
- Ok(())
+
+ r = 0;
+ for v in self {
+ r += 1;
+ }
+
+ Ok(r)
}
}
diff --git a/src/tests.rs b/src/tests.rs
@@ -79,6 +79,7 @@ fn test_feed_mix() {
#[test]
#[cfg(feature = "fs")]
fn test_feed_write() {
+ let r: usize;
let fs = Fs{};
let f: NamedTempFile;
let fr: File;
@@ -88,6 +89,7 @@ fn test_feed_write() {
seq.add_from(feed);
f = NamedTempFile::new().unwrap();
fr = f.reopen().unwrap();
- seq.write_to(f).unwrap();
+ r = seq.write_to(f).unwrap();
+ assert_eq!(r, 15);
assert_eq!(fr.metadata().unwrap().len(), 301);
}