pub trait ContextState { }Expand description
At trait setting up a state machine as described below.
Its implementors represent one specific state defining the amount and the
type of data the Context type holds at that moment.
Implementors§
impl ContextState for HasExistingContent
In addition to the HasSettings the YAML headers of all clipboard
Content objects are registered as front matter variables fm.fm* in the
Context.
This stage is also used for the TemplateKind::FromTextFile template.
In this case the last inserted Content comes from the text file
the command line parameter <path> points to. This adds the following key:
TMPL_VAR_DOC
This state can evolve as the
insert_front_matter_and_raw_text_from_existing_content() function can be
called several times.
| State order | |
|---|---|
| Previous state | HasSettings or HasExistingContent |
| Current state | HasExistingContent |
| Next state | ReadyForContentTemplate |
impl ContextState for HasSettings
The Context has the following initialized and valid fields: path,
dir_path, root_path and ct. The context ct contains data from
insert_config_vars() and insert_settings().
Context<HasSettings> has the following variables set:
TMPL_VAR_CURRENT_SCHEMETMPL_VAR_DIR_PATHin sync withself.dir_pathandTMPL_VAR_DOC_FILE_DATEin sync withself.doc_file_date(only if available).TMPL_VAR_EXTENSION_DEFAULTTMPL_VAR_LANGTMPL_VAR_PATHin sync withself.path,TMPL_VAR_ROOT_PATHin sync withself.root_path.TMPL_VAR_SCHEME_SYNC_DEFAULT.TMPL_VAR_USERNAME
The variables are inserted by the following methods: self.from(),
self.insert_config_vars() and self.insert_settings().
Once this state is achieved, Context is constant and write protected until
the next state transition.
| State order | |
|---|---|
| Previous state | Invalid |
| Current state | HasSettings |
| Next state | ReadyForFilenameTemplate or HasExistingContent |
impl ContextState for Invalid
The Context object is in an invalid state. Either it was not initialized
or its data does not correspond any more to the Content it represents.
| State order | |
|---|---|
| Previous state | none |
| Current state | Invalid |
| Next state | HasSettings |
impl ContextState for ReadyForContentTemplate
This marker state means that enough information have been collected
in the HasExistingContent state to be passed to a
content template renderer.
Once this state is achieved, Context is constant and write protected until
the next state transition.
| State order | |
|---|---|
| Previous state | HasExistingContent |
| Current state | ReadyForContentTemplate |
| Next state | none |
impl ContextState for ReadyForFilenameTemplate
In addition to HasSettings, the context.ct contains template variables
deserialized from some note’s front matter. E.g. a field named title:
appears in the context as fm.fm_title template variable.
In Note objects the Content is always associated with a
Context<ReadyForFilenameTemplate>.
Once this state is achieved, Context is constant and write protected until
the next state transition.
| State order | |
|---|---|
| Previous state | HasSettings |
| Current state | ReadyForFilenameTemplate |
| Next state | none or ReadyForHtmlTemplate |
impl ContextState for ReadyForHtmlErrorTemplate
The Context has all data for the intended template.
TMPL_HTML_VAR_DOC_ERRORfromerror_messageTMPL_HTML_VAR_DOC_TEXTfromnote_erroneous_contentTMPL_HTML_VAR_VIEWER_DOC_JSfromviewer_doc_js
Once this state is achieved, Context is constant and write protected until
the next state transition.
| State order | |
|---|---|
| Previous state | HasSettings |
| Current state | ReadyForHtmlErrorTemplate |
| Next state | none |
impl ContextState for ReadyForHtmlTemplate
In addition to the ReadyForFilenameTemplate state this state has the
following variables set:
TMPL_HTML_VAR_EXPORTER_DOC_CSSTMPL_HTML_VAR_EXPORTER_HIGHLIGHTING_CSSTMPL_HTML_VAR_EXPORTER_HIGHLIGHTING_CSSTMPL_HTML_VAR_VIEWER_DOC_CSS_PATHTMPL_HTML_VAR_VIEWER_DOC_CSS_PATH_VALUETMPL_HTML_VAR_VIEWER_DOC_JSfromviewer_doc_jsTMPL_HTML_VAR_VIEWER_HIGHLIGHTING_CSS_PATHTMPL_HTML_VAR_VIEWER_HIGHLIGHTING_CSS_PATH_VALUETMPL_VAR_DOC
Once this state is achieved, Context is constant and write protected until
the next state transition.
| State order | |
|---|---|
| Previous state | ReadyForFilenameTemplate |
| Current state | ReadyForHtmlTemplate |
| Next state | none |