Trait ContextState

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

Source§

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_SCHEME
  • TMPL_VAR_DIR_PATH in sync with self.dir_path and
  • TMPL_VAR_DOC_FILE_DATE in sync with self.doc_file_date (only if available).
  • TMPL_VAR_EXTENSION_DEFAULT
  • TMPL_VAR_LANG
  • TMPL_VAR_PATH in sync with self.path,
  • TMPL_VAR_ROOT_PATH in sync with self.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 stateInvalid
Current stateHasSettings
Next stateReadyForFilenameTemplate or HasExistingContent
Source§

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 statenone
Current stateInvalid
Next stateHasSettings