pub struct Config { /* private fields */ }Expand description
The Config object represents the configuration of the app. You instantiate it by providing
the path to $TILLER_HOME and from there it loads $TILLER_HOME/config.json. It provides
paths to other items that are either configurable or are expected in a certain location within
the tiller home directory.
Implementations§
Source§impl Config
impl Config
Sourcepub async fn create(
dir: impl Into<PathBuf>,
secret_file: &Path,
url: &str,
) -> Result<Self>
pub async fn create( dir: impl Into<PathBuf>, secret_file: &Path, url: &str, ) -> Result<Self>
Creates the data directory, its subdirectories and:
- Creates an initial
config.jsonfile usingsheet_urlalong with default settings - Copies
secret_fileinto its default location in the data dir.
§Arguments
dir- The directory that will be the root of data directory, e.g.$HOME/tillersecret_file- The downloaded OAuth 2.0 client credentials JSON needed to start the Google OAuth workflow. This will be copied from thesecret_filepath to its default location and name in the data directory.sheet_url- The URL of the Google Sheet where the Tiller financial data is stored. e.g.https://docs.google.com/spreadsheets/d/1a7Km9FxQwRbPt82JvN4LzYpH5OcGnWsT6iDuE3VhMjX
§Errors
- Returns an error if any file operations fail.
Sourcepub async fn load(tiller_home: impl Into<PathBuf>) -> Result<Self>
pub async fn load(tiller_home: impl Into<PathBuf>) -> Result<Self>
This will
- validate that the
tiller_homeexists and that the config file exists - load the config file
- validate that the backups and secrets directories exist
- return the loaded configuration object
pub fn root(&self) -> &Path
pub fn config_path(&self) -> &Path
pub fn backups(&self) -> &Path
pub fn secrets(&self) -> &Path
pub fn sheet_url(&self) -> &str
pub fn spreadsheet_id(&self) -> &str
pub fn sqlite_path(&self) -> &Path
pub fn backup_copies(&self) -> u32
Sourcepub fn client_secret_path(&self) -> PathBuf
pub fn client_secret_path(&self) -> PathBuf
Returns the stored client_secret_path if it is absolute, otherwise resolves the relative path.
Sourcepub fn token_path(&self) -> PathBuf
pub fn token_path(&self) -> PathBuf
Returns the stored token_path if it is absolute, otherwise resolves the relative path.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Config
impl !RefUnwindSafe for Config
impl Send for Config
impl Sync for Config
impl Unpin for Config
impl !UnwindSafe for Config
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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