Struct WorkflowBuilder

Source
pub struct WorkflowBuilder<W> { /* private fields */ }
Expand description

Typestate of the WorkflowBuilder.

Implementations§

Source§

impl<'a> WorkflowBuilder<SyncFilename<'a>>

Source

pub fn new(path: &'a Path) -> Self

Constructor of all workflows. The path points

  1. to an existing note file, or
  2. to a directory where the new note should be created, or
  3. to a non-Tp-Note file that will be annotated.

For cases 2. and 3. upgrade the WorkflowBuilder with upgrade() to add additional input data.

Source

pub fn upgrade<T: Content, F: Fn(TemplateKind) -> TemplateKind>( self, scheme_new_default: &'a str, html_clipboard: &'a T, txt_clipboard: &'a T, stdin: &'a T, tk_filter: F, ) -> WorkflowBuilder<SyncFilenameOrCreateNew<'a, T, F>>

Upgrade the WorkflowBuilder to enable also the creation of new note files. It requires providing additional input data:

New notes are created by inserting Tp-Note’s environment in a template. The template set being used, is determined by scheme_new_default. If the note to be created exists already, append a so called copy_counter to the filename and try to save it again. In case this does not succeed either, increment the copy_counter until a free filename is found. The returned path points to the (new) note file on disk. Depending on the context, Tp-Note chooses one TemplateKind to operate (c.f. tpnote_lib::template::TemplateKind::from()). The tk-filter allows to overwrite this choice, e.g. you may set TemplateKind::None under certain circumstances. This way the caller can disable the filename synchronization and inject behavior like --no-filename-sync.

Some templates insert the content of the clipboard or the standard input pipe. The input data (can be empty) must be provided with the parameters clipboard and stdin. The templates expect text with markup or HTML. In case of HTML, the content must start with <!DOCTYPE html or <html

Source

pub fn build(self) -> Workflow<SyncFilename<'a>>

Finalize the build.

Source§

impl<'a, T: Content, F: Fn(TemplateKind) -> TemplateKind> WorkflowBuilder<SyncFilenameOrCreateNew<'a, T, F>>

Source

pub fn html_export(&mut self, path: &'a Path, local_link_kind: LocalLinkKind)

Set a flag, that the workflow also stores an HTML-rendition of the note file next to it. This optional HTML rendition is performed just before returning and does not affect any above described operation.

Source

pub fn force_scheme(&mut self, scheme: &'a str)

Overwrite the default scheme.

Source

pub fn force_lang(&mut self, force_lang: &'a str)

By default, the natural language, the note is written in is guessed from the title and subtitle. This disables the automatic guessing and forces the language.

Source

pub fn build(self) -> Workflow<SyncFilenameOrCreateNew<'a, T, F>>

Finalize the build.

Trait Implementations§

Source§

impl<W: Clone> Clone for WorkflowBuilder<W>

Source§

fn clone(&self) -> WorkflowBuilder<W>

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<W: Debug> Debug for WorkflowBuilder<W>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<W> Freeze for WorkflowBuilder<W>
where W: Freeze,

§

impl<W> RefUnwindSafe for WorkflowBuilder<W>
where W: RefUnwindSafe,

§

impl<W> Send for WorkflowBuilder<W>
where W: Send,

§

impl<W> Sync for WorkflowBuilder<W>
where W: Sync,

§

impl<W> Unpin for WorkflowBuilder<W>
where W: Unpin,

§

impl<W> UnwindSafe for WorkflowBuilder<W>
where W: UnwindSafe,

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> MaybeSendSync for T