Skip to main content

Brain

Struct Brain 

Source
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 and settings.

Fields§

§store: Store

The data folder entries are read from and written to.

§tasks: Vec<Task>

Every entry, in no particular order.

§tag_colors: TagColors

Tag → 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.

§author: Author

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

Source

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

Source

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.

Source

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

Source

pub fn entry(&self, id: u32) -> Result<&Task, ApiError>

The entry with this id, or NotFound.

Source

pub fn add(&mut self, new: NewEntry) -> Result<u32>

Creates an entry and returns its id. Links must point at existing entries.

Source

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).

Source

pub fn comment(&mut self, id: u32, text: &str) -> Result<()>

Adds a timestamped comment, e.g. progress notes from an agent.

Source

pub fn describe(&mut self, id: u32, text: &str) -> Result<()>

Replaces the description.

Adds links from id to each of others and of repo_links (entries of the project’s other repositories), skipping ones it already has.

Source

pub fn search(&self, query: &str) -> Vec<&Task>

Entries matching every whitespace-separated term in their title, tags, description or comments (#term matches a tag prefix only), case-insensitive; tasks not done first, then newest first.

Source§

impl Brain

Source

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.

Source

pub fn set_project_description(&mut self, text: &str) -> Result<()>

Replaces the project’s description, on the card all its repositories share.

Source

pub fn set_repo_notes(&mut self, text: &str) -> Result<()>

Replaces this repository’s own notes about itself, on its .brain/project.md.

Source

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.

Source

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).

Source

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.

Source

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.

Removes every link to link, an entry of another repository of the project that’s gone.

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.

Relates two entries, or unrelates them if they already are: the link is added to id, and removed from whichever side stores it. Returns whether they are related now.

Source

pub fn set_description(&mut self, id: u32, text: &str) -> Result<bool>

Replaces the description. Returns whether ## headings had to become ###.

Source

pub fn add_comment(&mut self, id: u32, text: &str) -> Result<bool>

Adds a timestamped comment. Returns whether headings had to become ####.

Source

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 ####.

Source

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.

Source

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.

Source

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 ####.

Source

pub fn delete_comment(&mut self, id: u32, comment: usize) -> Result<()>

Deletes a comment.

Source

pub fn report_path(&self, view: &ReportView) -> PathBuf

Where the markdown export of view goes: <data dir>/reports/<name>.md.

Source

pub fn export_report(&self, view: &ReportView) -> Result<PathBuf>

Writes the report as markdown and returns the path.

Source

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

Source

pub fn calendar(&self, view: &CalendarView) -> Calendar

Computes the calendar for view: each day’s interactions and time worked.

Source§

impl Brain

Source

pub fn report(&self, view: &ReportView) -> Report

Computes the report for view: rows, breakdown columns, totals and the timeline.

Source§

impl Brain

Source

pub fn open(store: Store) -> Result<Self>

Loads every entry and the settings.

Source

pub fn read_only(store: Store) -> Result<Self>

Loads every entry and the settings 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.

Source

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.

Source

pub fn reload(&mut self) -> Result<()>

Re-reads every file from disk.

Source

pub fn task(&self, id: u32) -> Option<&Task>

The entry with this id.

Source

pub fn running(&self) -> impl Iterator<Item = &Task>

The tasks whose clock is running: those in doing, as many as the limit at most.

Source

pub fn person_doing(&self) -> Option<u32>

The task in doing that a person started, if any: there’s one at most.

Source

pub fn column(&self, status: Status) -> Vec<&Task>

Tasks with status, most recently moved there first.

Entries that link to the one with this id, oldest first.

Source

pub fn related(&self, id: u32) -> Vec<&Task>

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.

Source

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.

Source

pub fn all_tags(&self) -> Vec<String>

All tags in use, sorted.

Trait Implementations§

Source§

impl Debug for Brain

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl !Freeze for Brain

§

impl !RefUnwindSafe for Brain

§

impl !Sync for Brain

§

impl Send for Brain

§

impl Unpin for Brain

§

impl UnsafeUnpin for Brain

§

impl UnwindSafe for Brain

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

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

fn try_from(value: U) -> Result<T, !>

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.