pub struct ConfigFile { /* private fields */ }Expand description
This struct holds the configuration data to use the Jira API (authentication info and Jira base_url).
Implementations§
Source§impl ConfigFile
Implementation of ConfigFile
impl ConfigFile
Implementation of ConfigFile
§Methods
new(auth_token: String, jira_url: String) -> ConfigFile- creates a new instance of ConfigFile- default() -> ConfigFile - creates a new instance of ConfigFile with default values
write_to_file(file: &str) -> Result<(), std::io::Error>- writes the ConfigFile to a fileread_from_file(file: &str) -> Result<ConfigFile, std::io::Error>- reads the ConfigFile from a fileget_auth() -> AuthSection- gets the AuthSection from the ConfigFileget_jira() -> JiraSection- gets the JiraSection from the ConfigFileset_auth(auth: AuthSection)- sets the AuthSection in the ConfigFileset_jira(jira: JiraSection)- sets the JiraSection in the ConfigFileset_standard_resolution(standard_resolution: String)- sets the standard_resolution in the ConfigFileget_standard_resolution() -> String- gets the standard_resolution from the ConfigFileset_standard_resolution_comment(standard_resolution_comment: String)- sets the standard_resolution_comment in the ConfigFileget_standard_resolution_comment() -> String- gets the standard_resolution_comment from the Configadd_transition_name(key: String, value: String)- adds a transition_name to the ConfigFileget_transition_name(key: &str) -> Option<String>- gets a transition_name from the ConfigFile
Sourcepub fn new(
auth_token: String,
jira_url: String,
standard_resolution: String,
standard_resolution_comment: String,
transitions_names: Table,
yara: YaraSection,
) -> ConfigFile
pub fn new( auth_token: String, jira_url: String, standard_resolution: String, standard_resolution_comment: String, transitions_names: Table, yara: YaraSection, ) -> ConfigFile
Create a new ConfigFile struct.
§Arguments
- auth_token - The authentication token to be used with the Jira API.
- jira_url - The base_url for the Jira API.
- standard_resolution - The standard resolution to be used when resolving an issue.
- standard_resolution_comment - The standard comment to be used when resolving an issue.
- transitions_names - The transitions names to be used when transitioning an issue.
- yara - The YARA scanner configuration section.
§Returns
- A new ConfigFile struct.
§Examples
use jirust_cli::config::config_file::{ConfigFile, YaraSection};
use toml::Table;
let config = ConfigFile::new("auth_token".to_string(), "jira_url".to_string(), "standard_resolution".to_string(), "standard_resolution_comment".to_string(), Table::new(), YaraSection::default());
assert_eq!(config.get_auth_key(), "auth_token");
assert_eq!(config.get_jira_url(), "jira_url");
assert_eq!(config.get_standard_resolution(), "standard_resolution");
assert_eq!(config.get_standard_resolution_comment(), "standard_resolution_comment");Sourcepub fn set_auth_key(&mut self, auth_token: String)
pub fn set_auth_key(&mut self, auth_token: String)
Set the authentication token for the ConfigFile struct. This is the token that will be used to authenticate with the Jira API.
§Arguments
- auth_token - The authentication token to be used with the Jira API.
§Examples
use jirust_cli::config::config_file::ConfigFile;
let mut config = ConfigFile::default();
config.set_auth_key("auth_key".to_string());
assert_eq!(config.get_auth_key(), "auth_key");Sourcepub fn get_auth_key(&self) -> &str
pub fn get_auth_key(&self) -> &str
Get the authentication token for the ConfigFile struct. This is the token that will be used to authenticate with the Jira API. This is useful for getting the current value of the authentication token.
§Returns
- The authentication token to be used with the Jira API.
§Examples
use jirust_cli::config::config_file::{ConfigFile, YaraSection};
use toml::Table;
let config = ConfigFile::new("auth_token".to_string(), "jira_url".to_string(), "standard_resolution".to_string(), "standard_resolution_comment".to_string(), Table::new(), YaraSection::default());
let auth_key = config.get_auth_key();
assert_eq!(auth_key, "auth_token");Sourcepub fn set_jira_url(&mut self, jira_url: String)
pub fn set_jira_url(&mut self, jira_url: String)
Set the Jira URL for the ConfigFile struct. This is the base URL for the Jira API.
§Arguments
- jira_url - The base URL for the Jira API.
§Examples
use jirust_cli::config::config_file::ConfigFile;
let mut config = ConfigFile::default();
config.set_jira_url("jira_url".to_string());
assert_eq!(config.get_jira_url(), "jira_url");Sourcepub fn get_jira_url(&self) -> &str
pub fn get_jira_url(&self) -> &str
Get the Jira URL for the ConfigFile struct. This is the base URL for the Jira API.
§Returns
- The base URL for the Jira API.
§Examples
use jirust_cli::config::config_file::{ConfigFile, YaraSection};
use toml::Table;
let config = ConfigFile::new("auth_token".to_string(), "jira_url".to_string(), "standard_resolution".to_string(), "standard_resolution_comment".to_string(), Table::new(), YaraSection::default());
let jira_url = config.get_jira_url();
assert_eq!(jira_url, "jira_url");Sourcepub fn set_standard_resolution(&mut self, standard_resolution: String)
pub fn set_standard_resolution(&mut self, standard_resolution: String)
Set the standard resolution for the ConfigFile struct. This is the standard resolution that will be used when resolving an issue.
§Arguments
- standard_resolution - The standard resolution to be used when resolving an issue.
§Examples
use jirust_cli::config::config_file::ConfigFile;
let mut config = ConfigFile::default();
config.set_standard_resolution("standard_resolution".to_string());
assert_eq!(config.get_standard_resolution(), "standard_resolution");Sourcepub fn get_standard_resolution(&self) -> &String
pub fn get_standard_resolution(&self) -> &String
Get the standard resolution for the ConfigFile struct. This is the standard resolution that will be used when resolving an issue.
§Returns
- The standard resolution to be used when resolving an issue.
§Examples
use jirust_cli::config::config_file::{ConfigFile, YaraSection};
use toml::Table;
let config = ConfigFile::new("auth_token".to_string(), "jira_url".to_string(), "standard_resolution".to_string(), "standard_resolution_comment".to_string(), Table::new(), YaraSection::default());
let standard_resolution = config.get_standard_resolution();
assert_eq!(config.get_standard_resolution(), "standard_resolution");Sourcepub fn set_standard_resolution_comment(
&mut self,
standard_resolution_comment: String,
)
pub fn set_standard_resolution_comment( &mut self, standard_resolution_comment: String, )
Set the standard resolution comment for the ConfigFile struct. This is the standard resolution comment that will be used when resolving an issue.
§Arguments
- standard_resolution_comment - The standard resolution comment to be used when resolving an issue.
§Examples
use jirust_cli::config::config_file::ConfigFile;
let mut config = ConfigFile::default();
config.set_standard_resolution_comment("standard_resolution_comment".to_string());
assert_eq!(config.get_standard_resolution_comment(), "standard_resolution_comment");Sourcepub fn get_standard_resolution_comment(&self) -> &String
pub fn get_standard_resolution_comment(&self) -> &String
Get the standard resolution comment for the ConfigFile struct. This is the standard resolution comment that will be used when resolving an issue.
§Returns
- The standard resolution comment to be used when resolving an issue.
§Examples
use jirust_cli::config::config_file::{ConfigFile, YaraSection};
use toml::Table;
let config = ConfigFile::new("auth_token".to_string(), "jira_url".to_string(), "standard_resolution".to_string(), "standard_resolution_comment".to_string(), Table::new(), YaraSection::default());
let standard_resolution_comment = config.get_standard_resolution_comment();
assert_eq!(standard_resolution_comment, "standard_resolution_comment");Sourcepub fn add_transition_name(&mut self, key: String, value: String)
pub fn add_transition_name(&mut self, key: String, value: String)
Add a transition name to the ConfigFile struct. This is used to store the transition name for a specific transition. This is used to transition an issue to a specific state. The key is the transition internal identifier and the value is the transition name.
§Arguments
- key - The transition internal identifier.
- value - The transition name.
§Examples
use jirust_cli::config::config_file::ConfigFile;
let mut config = ConfigFile::default();
config.add_transition_name("transition_key".to_string(), "Transition name".to_string());
assert_eq!(config.get_transition_name("transition_key"), Some(vec!["Transition name".to_string()]));Sourcepub fn get_transition_name(&self, key: &str) -> Option<Vec<String>>
pub fn get_transition_name(&self, key: &str) -> Option<Vec<String>>
Get the transition name for a specific transition internal identifier. This is used to transition an issue to a specific state. The key is the transition internal identifier and the value is the transition name. If the transition internal identifier does not exist, None is returned.
§Arguments
- key - The transition internal identifier.
§Returns
- The transition name for the specific transition internal identifier.
§Examples
use jirust_cli::config::config_file::ConfigFile;
let mut config = ConfigFile::default();
config.add_transition_name("transition_key".to_string(), "Transition name".to_string());
assert_eq!(config.get_transition_name("transition_key"), Some(vec!["Transition name".to_string()]));Sourcepub fn get_yara_section(&self) -> &YaraSection
pub fn get_yara_section(&self) -> &YaraSection
Sourcepub fn get_yara_rules_source(&self) -> &str
pub fn get_yara_rules_source(&self) -> &str
Sourcepub fn get_yara_rules_directory(&self) -> &str
pub fn get_yara_rules_directory(&self) -> &str
Get the YARA rules directory from the ConfigFile struct.
§Returns
- The YARA rules directory name (relative to ~/.jirust-cli/).
Sourcepub fn get_yara_cache_file(&self) -> &str
pub fn get_yara_cache_file(&self) -> &str
Get the YARA cache file from the ConfigFile struct.
§Returns
- The YARA cache file name (relative to ~/.jirust-cli/).
Sourcepub fn get_yara_cache_version_file(&self) -> &str
pub fn get_yara_cache_version_file(&self) -> &str
Get the YARA cache version file from the ConfigFile struct.
§Returns
- The YARA cache version file name (relative to ~/.jirust-cli/).
Sourcepub fn set_yara_rules_source(&mut self, source: String)
pub fn set_yara_rules_source(&mut self, source: String)
Set the YARA rules source URL for the ConfigFile struct.
§Arguments
- source - The YARA rules source URL (git repo or zip file).
Sourcepub fn set_yara_rules_directory(&mut self, directory: String)
pub fn set_yara_rules_directory(&mut self, directory: String)
Set the YARA rules directory for the ConfigFile struct.
§Arguments
- directory - The YARA rules directory name (relative to ~/.jirust-cli/).
Sourcepub fn set_yara_cache_file(&mut self, file: String)
pub fn set_yara_cache_file(&mut self, file: String)
Set the YARA cache file for the ConfigFile struct.
§Arguments
- file - The YARA cache file name (relative to ~/.jirust-cli/).
Sourcepub fn set_yara_cache_version_file(&mut self, file: String)
pub fn set_yara_cache_version_file(&mut self, file: String)
Set the YARA cache version file for the ConfigFile struct.
§Arguments
- file - The YARA cache version file name (relative to ~/.jirust-cli/).
Sourcepub fn write_to_file(&self, file_path: &str) -> Result<(), Error>
pub fn write_to_file(&self, file_path: &str) -> Result<(), Error>
Stores the configuration to a file. This will overwrite the file if it already exists.
§Arguments
- file_path - The path to the file to write the configuration to.
§Returns
- A Result containing either an empty Ok or an error.
§Examples
use jirust_cli::config::config_file::{ConfigFile, YaraSection};
use toml::Table;
let config = ConfigFile::new("auth_token".to_string(), "jira_url".to_string(), "standard_resolution".to_string(), "standard_resolution_comment".to_string(), Table::new(), YaraSection::default());
let result = config.write_to_file("config.toml");
assert!(result.is_ok());Sourcepub fn read_from_file(file_path: &str) -> Result<ConfigFile, Error>
pub fn read_from_file(file_path: &str) -> Result<ConfigFile, Error>
Loads the configuration from a file. If the file does not exist, it will return a ConfigFile with default values. If the file is not valid toml, it will return an error. If the file is valid toml, it will return the ConfigFile.
§Arguments
- file_path - The path to the file to read the configuration from.
§Returns
- A Result containing either the ConfigFile or an error.
§Examples
use jirust_cli::config::config_file::ConfigFile;
use std::path::Path;
// Try both possible paths to handle different working directories
let config_path = if Path::new("config_example.toml").exists() {
"config_example.toml"
} else {
"jirust-cli/config_example.toml"
};
let config = ConfigFile::read_from_file(config_path);
assert!(config.clone().is_ok());
assert_eq!(config.clone().unwrap().get_auth_key(), "auth_key");
assert_eq!(config.clone().unwrap().get_jira_url(), "jira_url");Trait Implementations§
Source§impl Clone for ConfigFile
impl Clone for ConfigFile
Source§fn clone(&self) -> ConfigFile
fn clone(&self) -> ConfigFile
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ConfigFile
impl Debug for ConfigFile
Source§impl Default for ConfigFile
impl Default for ConfigFile
Source§fn default() -> ConfigFile
fn default() -> ConfigFile
Create a new ConfigFile struct with default values. This is useful for creating a new configuration file. The default values can be set using the set methods. The default values are:
- auth_token: “”
- jira_url: “”
- standard_resolution: “”
- standard_resolution_comment: “”
- transitions_names: Table::new()
- yara: YaraSection::default()
§Returns
- A new ConfigFile struct with default values.
§Examples
use jirust_cli::config::config_file::ConfigFile;
use toml::Table;
let config = ConfigFile::default();
assert_eq!(config.get_auth_key(), "");
assert_eq!(config.get_jira_url(), "");
assert_eq!(config.get_standard_resolution(), "");
assert_eq!(config.get_standard_resolution_comment(), "");Source§impl<'de> Deserialize<'de> for ConfigFile
impl<'de> Deserialize<'de> for ConfigFile
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Auto Trait Implementations§
impl Freeze for ConfigFile
impl RefUnwindSafe for ConfigFile
impl Send for ConfigFile
impl Sync for ConfigFile
impl Unpin for ConfigFile
impl UnwindSafe for ConfigFile
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> FmtForward for T
impl<T> FmtForward for T
Source§fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
self to use its Binary implementation when Debug-formatted.Source§fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
self to use its Display implementation when
Debug-formatted.Source§fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
self to use its LowerExp implementation when
Debug-formatted.Source§fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
self to use its LowerHex implementation when
Debug-formatted.Source§fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
self to use its Octal implementation when Debug-formatted.Source§fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
self to use its Pointer implementation when
Debug-formatted.Source§fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
self to use its UpperExp implementation when
Debug-formatted.Source§fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
self to use its UpperHex implementation when
Debug-formatted.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>
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>
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 moreSource§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
Source§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
Source§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moreSource§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moreSource§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
Source§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R,
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
Source§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
self, then passes self.as_ref() into the pipe function.Source§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
self, then passes self.as_mut() into the pipe
function.Source§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
self, then passes self.deref() into the pipe function.Source§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<T> Tap for T
impl<T> Tap for T
Source§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Borrow<B> of a value. Read moreSource§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
BorrowMut<B> of a value. Read moreSource§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
AsRef<R> view of a value. Read moreSource§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
AsMut<R> view of a value. Read moreSource§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Deref::Target of a value. Read moreSource§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Deref::Target of a value. Read moreSource§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap() only in debug builds, and is erased in release builds.Source§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
.tap_borrow() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
.tap_borrow_mut() only in debug builds, and is erased in release
builds.Source§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
.tap_ref() only in debug builds, and is erased in release
builds.Source§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
.tap_ref_mut() only in debug builds, and is erased in release
builds.Source§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
.tap_deref() only in debug builds, and is erased in release
builds.