pub struct Brain {
pub store: Store,
pub tasks: Vec<Task>,
pub tag_colors: TagColors,
pub warnings: Vec<String>,
pub project: Option<ProjectInfo>,
pub central: Option<PathBuf>,
pub author: Author,
}Expand description
Every entry in the data folder, with the tag colors.
Fields§
§store: StoreThe data folder entries are read from and written to.
tasks: Vec<Task>Every entry, in no particular order.
tag_colors: TagColorsTag → color assignments, kept in tags.md.
warnings: Vec<String>Files skipped by the last load, with why; the desktop app shows them.
project: Option<ProjectInfo>What a project’s repository knows of its project; None for the central brain.
central: Option<PathBuf>The central brain, which lists the projects and keeps their shared cards. None (as from
Brain::open) leaves the project’s description and sibling repositories out.
Who the comments and status changes made through this brain are recorded as: a person unless the command line found it runs for an agent.
Implementations§
Source§impl Brain
impl Brain
Sourcepub fn context_markdown(&self) -> String
pub fn context_markdown(&self) -> String
Active tasks by status, the latest done, then decisions and notes, newest first, each as
- #id title #tag.
Source§impl Brain
impl Brain
Sourcepub fn entry_text(&self, id: u32) -> Result<String, ApiError>
pub fn entry_text(&self, id: u32) -> Result<String, ApiError>
The entry for an agent to read: state, description, comments, related entries, the latest status changes and the time tracked.
Sourcepub fn search_text(&self, query: &str) -> String
pub fn search_text(&self, query: &str) -> String
Search results as lines, best first, at most SEARCH_LIMIT, then how many more matched.
Source§impl Brain
impl Brain
Sourcepub fn add(&mut self, new: NewEntry) -> Result<u32>
pub fn add(&mut self, new: NewEntry) -> Result<u32>
Creates an entry and returns its id. Links must point at existing entries.
Sourcepub fn change_status(&mut self, id: u32, status: Status) -> Result<()>
pub fn change_status(&mut self, id: u32, status: Status) -> Result<()>
Moves a task to status; doing starts its clock (refused for a person who already runs a task).
Sourcepub fn comment(&mut self, id: u32, text: &str) -> Result<()>
pub fn comment(&mut self, id: u32, text: &str) -> Result<()>
Adds a timestamped comment, e.g. progress notes from an agent.
Sourcepub fn link(
&mut self,
id: u32,
others: &[u32],
repo_links: &[RepoLink],
) -> Result<()>
pub fn link( &mut self, id: u32, others: &[u32], repo_links: &[RepoLink], ) -> Result<()>
Adds links from id to each of others and of repo_links (entries of the project’s other
repositories), skipping ones it already has. Each entry of this brain it wasn’t related to logs it on both
sides; each link to another repository’s entry that it didn’t have, here only, as that file isn’t written.
Source§impl Brain
impl Brain
Sourcepub fn set_status(&mut self, id: u32, status: Status) -> Result<bool>
pub fn set_status(&mut self, id: u32, status: Status) -> Result<bool>
Moves a task to status, recording when. doing starts its clock; for a person, it’s refused while
doing holds a task a person started: making room is their call, never a side effect. Agents start
as many as they work on. Returns whether anything changed.
Sourcepub fn set_project_description(&mut self, text: &str) -> Result<()>
pub fn set_project_description(&mut self, text: &str) -> Result<()>
Replaces the project’s description, on the card all its repositories share.
Sourcepub fn set_repo_notes(&mut self, text: &str) -> Result<()>
pub fn set_repo_notes(&mut self, text: &str) -> Result<()>
Replaces this repository’s own notes about itself, on its .brain/project.md.
Sourcepub fn park_people_running(&mut self) -> Result<()>
pub fn park_people_running(&mut self) -> Result<()>
Parks every running task a person started, when they stop for the day. Agents’ keep running: they may still be at work, and each agent closes its own.
Sourcepub fn update(&mut self, id: u32, title: &str, tags: Vec<String>) -> Result<()>
pub fn update(&mut self, id: u32, title: &str, tags: Vec<String>) -> Result<()>
Saves a new title and tags (a new title also renames the file), logging what changed.
Sourcepub fn rename_tag(&mut self, old: &str, new: &str) -> Result<Vec<u32>>
pub fn rename_tag(&mut self, old: &str, new: &str) -> Result<Vec<u32>>
Renames tag old to new in every entry that has it, logging it in each; an entry that has both just loses
old. new takes old’s color unless it has one. Returns the ids of the entries changed, lowest first.
Sourcepub fn delete(&mut self, id: u32) -> Result<()>
pub fn delete(&mut self, id: u32) -> Result<()>
Deletes the entry’s file, after removing the links other entries have to it. The links go first: if a save fails, the entry is still there and nothing points nowhere.
Sourcepub fn move_to(&mut self, id: u32, to: &mut Brain) -> Result<u32>
pub fn move_to(&mut self, id: u32, to: &mut Brain) -> Result<u32>
Moves the entry to to, another brain (another project or repository, or the central one), and
returns its id there: a new one, since each brain numbers its own. Everything else comes
along (status, history, sessions, description, comments, tags) except its links, which name it by
its id here, so they’re dropped on both sides (links to other repositories too). A running task keeps
its clock; one a person started needs room in to’s doing, as starting it there would.
The entry is saved in to before it’s deleted here: if something fails in between, it’s in both
brains rather than in neither.
Sourcepub fn drop_repo_links_to(&mut self, link: &RepoLink) -> Result<()>
pub fn drop_repo_links_to(&mut self, link: &RepoLink) -> Result<()>
Removes every link to link, an entry of another repository of the project that’s gone.
Sourcepub fn toggle_repo_link(
&mut self,
id: u32,
other: &mut Brain,
other_id: u32,
) -> Result<bool>
pub fn toggle_repo_link( &mut self, id: u32, other: &mut Brain, other_id: u32, ) -> Result<bool>
Relates entry id to entry other_id of other, another repository of this brain’s project, or
unrelates them if they already are: the link is added here, and removed from whichever side stores
it. Returns whether they are related now.
Sourcepub fn toggle_link(&mut self, id: u32, other: u32) -> Result<bool>
pub fn toggle_link(&mut self, id: u32, other: u32) -> Result<bool>
Relates two entries, or unrelates them if they already are: the link is added to id, and
removed from whichever side stores it. Both log it. Returns whether they are related now.
Sourcepub fn set_description(&mut self, id: u32, text: &str) -> Result<bool>
pub fn set_description(&mut self, id: u32, text: &str) -> Result<bool>
Replaces the description, logging that it changed. Returns whether ## headings had to become ###.
Sourcepub fn add_comment(&mut self, id: u32, text: &str) -> Result<bool>
pub fn add_comment(&mut self, id: u32, text: &str) -> Result<bool>
Adds a timestamped comment. Returns whether headings had to become ####.
Sourcepub fn ask(&mut self, id: u32, question: &str) -> Result<bool>
pub fn ask(&mut self, id: u32, question: &str) -> Result<bool>
Asks the user a question on a task and parks it, until a person answers with a comment (see
Task::asked). Returns whether headings had to become ####.
Sourcepub fn propose(&mut self, id: u32, decision: NewEntry) -> Result<u32>
pub fn propose(&mut self, id: u32, decision: NewEntry) -> Result<u32>
Proposes a decision for task id, which waits for a person to accept or reject it: the decision
is created as proposed, linked to the task, and the task asks about it and is parked. Returns
the decision’s id.
Sourcepub fn resolve(
&mut self,
id: u32,
state: DecisionState,
reason: &str,
) -> Result<bool>
pub fn resolve( &mut self, id: u32, state: DecisionState, reason: &str, ) -> Result<bool>
Accepts or rejects decision id, with reason (needed to reject), and answers the tasks that wait
on it. A decision can be reconsidered: an accepted one rejected later, and back. Returns false if it
already was in state.
Sourcepub fn update_comment(
&mut self,
id: u32,
comment: usize,
text: &str,
) -> Result<bool>
pub fn update_comment( &mut self, id: u32, comment: usize, text: &str, ) -> Result<bool>
Changes a comment’s text and marks it edited, unless the text is unchanged.
Returns whether headings had to become ####.
Sourcepub fn report_path(&self, view: &ReportView) -> PathBuf
pub fn report_path(&self, view: &ReportView) -> PathBuf
Where the markdown export of view goes: <data dir>/reports/<name>.md.
Sourcepub fn export_report(&self, view: &ReportView) -> Result<PathBuf>
pub fn export_report(&self, view: &ReportView) -> Result<PathBuf>
Writes the report as markdown and returns the path.
Sourcepub fn write_report(
&self,
report: &Report,
view: &ReportView,
) -> Result<PathBuf>
pub fn write_report( &self, report: &Report, view: &ReportView, ) -> Result<PathBuf>
Writes report, made for view, to this brain’s reports/ as markdown and returns the path;
for a report computed elsewhere, such as several brains’ merged.
Source§impl Brain
impl Brain
Sourcepub fn calendar(&self, view: &CalendarView) -> Calendar
pub fn calendar(&self, view: &CalendarView) -> Calendar
Computes the calendar for view: each day’s interactions and time worked.
Source§impl Brain
impl Brain
Sourcepub fn report(&self, view: &ReportView) -> Report
pub fn report(&self, view: &ReportView) -> Report
Computes the report for view: rows, breakdown columns, totals and the timeline.
Source§impl Brain
impl Brain
Sourcepub fn read_only(store: Store) -> Result<Self>
pub fn read_only(store: Store) -> Result<Self>
Loads every entry and the tag colors as the files have them, writing nothing: for reading a brain
nobody is working in, such as another repository’s to show links to it, or to complete a command
line. Brain::open also repairs what it finds, in files that may be in another git repository.
Sourcepub fn open_in(store: Store, central: &Path) -> Result<Self>
pub fn open_in(store: Store, central: &Path) -> Result<Self>
Loads every entry, knowing the central brain at central (see Brain::central), and so the
project’s other repositories, whose deleted entries’ links it drops.
Sourcepub fn running(&self) -> impl Iterator<Item = &Task>
pub fn running(&self) -> impl Iterator<Item = &Task>
The tasks whose clock is running: those in doing.
Sourcepub fn person_doing(&self) -> Option<u32>
pub fn person_doing(&self) -> Option<u32>
The task in doing that a person started, if any: there’s one at most.
Sourcepub fn column(&self, status: Status) -> Vec<&Task>
pub fn column(&self, status: Status) -> Vec<&Task>
Tasks with status, most recently moved there first.
Sourcepub fn backlinks(&self, id: u32) -> Vec<&Task>
pub fn backlinks(&self, id: u32) -> Vec<&Task>
Entries that link to the one with this id, oldest first.
Entries related to the one with this id, whichever side stores the link: notes, then decisions, then tasks, newest first within each.
Whether the two entries are related, whichever side stores the link.
Sourcepub fn sibling(&self, repo: &str) -> Option<Brain>
pub fn sibling(&self, repo: &str) -> Option<Brain>
The brain of the project’s repository named repo, read from disk without changing it, to check or
show links to its entries. None when this brain isn’t in a project, the project has no such other
repository, or its folder is gone: it’s never created here.
Entries of the project’s other repositories related to the one with this id, whichever side
stores the link, as (repository, entry): by repository, then as Brain::related orders them.
A repository that can’t be read, or an entry deleted there since, is left out.
All tags in use, sorted.