pub struct Draft { /* private fields */ }Expand description
Manages staged LinkedIn drafts for a set of blog posts.
Create with Draft::new, then call Draft::write_linkedin_drafts to
write .linkedin JSON files to the store directory and stamp the source
frontmatter with the creation date.
Implementations§
Source§impl Draft
impl Draft
Sourcepub fn new(
www_src_root: &Path,
blog_paths: &[PathBuf],
base_url: &str,
min_date: Option<Datetime>,
) -> Result<Self, DraftError>
pub fn new( www_src_root: &Path, blog_paths: &[PathBuf], base_url: &str, min_date: Option<Datetime>, ) -> Result<Self, DraftError>
Scan blog_paths under www_src_root, collect posts that have a
[linkedin] section with post text, and validate their length.
Posts are skipped when:
- The
[linkedin]section is absent. - Neither
descriptionnordescription_fileyields text. [linkedin].createdis already set (already drafted).[linkedin].publishedis already set (already posted).- The post’s
datefield predatesmin_date(when provided).
Returns DraftError::PostTooLong if any post’s text + link exceeds
LINKEDIN_POST_MAX_CHARS characters.
Returns DraftError::BlogPostListEmpty when no qualifying posts
remain.
Sourcepub fn write_linkedin_drafts(
&mut self,
store_dir: &Path,
) -> Result<&mut Self, DraftError>
pub fn write_linkedin_drafts( &mut self, store_dir: &Path, ) -> Result<&mut Self, DraftError>
Write .linkedin JSON files to store_dir for all collected posts,
and write created = <today> into each source file’s [linkedin]
section.
Posts that already have [linkedin].created set are skipped
(idempotent). The store directory is created if absent.
Sourcepub fn count_written(&self) -> usize
pub fn count_written(&self) -> usize
Number of .linkedin files written in the last call to
Draft::write_linkedin_drafts.