Removed docs headers

This commit is contained in:
veeso
2021-12-11 10:19:29 +01:00
committed by Christian Visintin
parent 2e0322bc0e
commit 027545f14c
52 changed files with 0 additions and 966 deletions

View File

@@ -60,8 +60,6 @@ pub struct ActivityManager {
} }
impl ActivityManager { impl ActivityManager {
/// ### new
///
/// Initializes a new Activity Manager /// Initializes a new Activity Manager
pub fn new(local_dir: &Path, ticks: Duration) -> Result<ActivityManager, HostError> { pub fn new(local_dir: &Path, ticks: Duration) -> Result<ActivityManager, HostError> {
// Prepare Context // Prepare Context
@@ -83,16 +81,12 @@ impl ActivityManager {
}) })
} }
/// ### set_filetransfer_params
///
/// Set file transfer params /// Set file transfer params
pub fn set_filetransfer_params(&mut self, params: FileTransferParams) { pub fn set_filetransfer_params(&mut self, params: FileTransferParams) {
// Put params into the context // Put params into the context
self.context.as_mut().unwrap().set_ftparams(params); self.context.as_mut().unwrap().set_ftparams(params);
} }
/// ### run
///
/// ///
/// Loop for activity manager. You need to provide the activity to start with /// Loop for activity manager. You need to provide the activity to start with
/// Returns the exitcode /// Returns the exitcode
@@ -114,8 +108,6 @@ impl ActivityManager {
// -- Activity Loops // -- Activity Loops
/// ### run_authentication
///
/// Loop for Authentication activity. /// Loop for Authentication activity.
/// Returns when activity terminates. /// Returns when activity terminates.
/// Returns the next activity to run /// Returns the next activity to run
@@ -168,8 +160,6 @@ impl ActivityManager {
result result
} }
/// ### run_filetransfer
///
/// Loop for FileTransfer activity. /// Loop for FileTransfer activity.
/// Returns when activity terminates. /// Returns when activity terminates.
/// Returns the next activity to run /// Returns the next activity to run
@@ -233,8 +223,6 @@ impl ActivityManager {
result result
} }
/// ### run_setup
///
/// `SetupActivity` run loop. /// `SetupActivity` run loop.
/// Returns when activity terminates. /// Returns when activity terminates.
/// Returns the next activity to run /// Returns the next activity to run
@@ -268,8 +256,6 @@ impl ActivityManager {
// -- misc // -- misc
/// ### init_config_client
///
/// Initialize configuration client /// Initialize configuration client
fn init_config_client() -> Result<ConfigClient, String> { fn init_config_client() -> Result<ConfigClient, String> {
// Get config dir // Get config dir

View File

@@ -32,8 +32,6 @@ use serde::{de::Error as DeError, Deserialize, Deserializer, Serialize, Serializ
use std::collections::HashMap; use std::collections::HashMap;
use std::str::FromStr; use std::str::FromStr;
/// ## UserHosts
///
/// UserHosts contains all the hosts saved by the user in the data storage /// UserHosts contains all the hosts saved by the user in the data storage
/// It contains both `Bookmark` /// It contains both `Bookmark`
#[derive(Deserialize, Serialize, Debug, Default)] #[derive(Deserialize, Serialize, Debug, Default)]
@@ -42,8 +40,6 @@ pub struct UserHosts {
pub recents: HashMap<String, Bookmark>, pub recents: HashMap<String, Bookmark>,
} }
/// ## Bookmark
///
/// Bookmark describes a single bookmark entry in the user hosts storage /// Bookmark describes a single bookmark entry in the user hosts storage
#[derive(Clone, Deserialize, Serialize, Debug, PartialEq)] #[derive(Clone, Deserialize, Serialize, Debug, PartialEq)]
pub struct Bookmark { pub struct Bookmark {
@@ -64,8 +60,6 @@ pub struct Bookmark {
pub s3: Option<S3Params>, pub s3: Option<S3Params>,
} }
/// ## S3Params
///
/// Connection parameters for Aws s3 protocol /// Connection parameters for Aws s3 protocol
#[derive(Clone, Deserialize, Serialize, Debug, PartialEq, Default)] #[derive(Clone, Deserialize, Serialize, Debug, PartialEq, Default)]
pub struct S3Params { pub struct S3Params {

View File

@@ -36,8 +36,6 @@ use std::path::PathBuf;
pub const DEFAULT_NOTIFICATION_TRANSFER_THRESHOLD: u64 = 536870912; // 512MB pub const DEFAULT_NOTIFICATION_TRANSFER_THRESHOLD: u64 = 536870912; // 512MB
#[derive(Deserialize, Serialize, Debug, Default)] #[derive(Deserialize, Serialize, Debug, Default)]
/// ## UserConfig
///
/// UserConfig contains all the configurations for the user, /// UserConfig contains all the configurations for the user,
/// supported by termscp /// supported by termscp
pub struct UserConfig { pub struct UserConfig {
@@ -46,8 +44,6 @@ pub struct UserConfig {
} }
#[derive(Deserialize, Serialize, Debug)] #[derive(Deserialize, Serialize, Debug)]
/// ## UserInterfaceConfig
///
/// UserInterfaceConfig provides all the keys to configure the user interface /// UserInterfaceConfig provides all the keys to configure the user interface
pub struct UserInterfaceConfig { pub struct UserInterfaceConfig {
pub text_editor: PathBuf, pub text_editor: PathBuf,
@@ -63,8 +59,6 @@ pub struct UserInterfaceConfig {
} }
#[derive(Deserialize, Serialize, Debug, Default)] #[derive(Deserialize, Serialize, Debug, Default)]
/// ## RemoteConfig
///
/// Contains configuratio related to remote hosts /// Contains configuratio related to remote hosts
pub struct RemoteConfig { pub struct RemoteConfig {
pub ssh_keys: HashMap<String, PathBuf>, // Association between host name and path to private key pub ssh_keys: HashMap<String, PathBuf>, // Association between host name and path to private key

View File

@@ -29,8 +29,6 @@ use serde::{de::DeserializeOwned, Serialize};
use std::io::{Read, Write}; use std::io::{Read, Write};
use thiserror::Error; use thiserror::Error;
/// ## SerializerError
///
/// Contains the error for serializer/deserializer /// Contains the error for serializer/deserializer
#[derive(std::fmt::Debug)] #[derive(std::fmt::Debug)]
pub struct SerializerError { pub struct SerializerError {
@@ -38,8 +36,6 @@ pub struct SerializerError {
msg: Option<String>, msg: Option<String>,
} }
/// ## SerializerErrorKind
///
/// Describes the kind of error for the serializer/deserializer /// Describes the kind of error for the serializer/deserializer
#[derive(Error, Debug)] #[derive(Error, Debug)]
pub enum SerializerErrorKind { pub enum SerializerErrorKind {
@@ -54,15 +50,11 @@ pub enum SerializerErrorKind {
} }
impl SerializerError { impl SerializerError {
/// ### new
///
/// Instantiate a new `SerializerError` /// Instantiate a new `SerializerError`
pub fn new(kind: SerializerErrorKind) -> SerializerError { pub fn new(kind: SerializerErrorKind) -> SerializerError {
SerializerError { kind, msg: None } SerializerError { kind, msg: None }
} }
/// ### new_ex
///
/// Instantiates a new `SerializerError` with description message /// Instantiates a new `SerializerError` with description message
pub fn new_ex(kind: SerializerErrorKind, msg: String) -> SerializerError { pub fn new_ex(kind: SerializerErrorKind, msg: String) -> SerializerError {
let mut err: SerializerError = SerializerError::new(kind); let mut err: SerializerError = SerializerError::new(kind);

View File

@@ -31,16 +31,12 @@ use super::{ExplorerOpts, FileExplorer, FileSorting, GroupDirs};
// Ext // Ext
use std::collections::VecDeque; use std::collections::VecDeque;
/// ## FileExplorerBuilder
///
/// Struct used to create a `FileExplorer` /// Struct used to create a `FileExplorer`
pub struct FileExplorerBuilder { pub struct FileExplorerBuilder {
explorer: Option<FileExplorer>, explorer: Option<FileExplorer>,
} }
impl FileExplorerBuilder { impl FileExplorerBuilder {
/// ### new
///
/// Build a new `FileExplorerBuilder` /// Build a new `FileExplorerBuilder`
pub fn new() -> Self { pub fn new() -> Self {
FileExplorerBuilder { FileExplorerBuilder {
@@ -48,15 +44,11 @@ impl FileExplorerBuilder {
} }
} }
/// ### build
///
/// Take FileExplorer out of builder /// Take FileExplorer out of builder
pub fn build(&mut self) -> FileExplorer { pub fn build(&mut self) -> FileExplorer {
self.explorer.take().unwrap() self.explorer.take().unwrap()
} }
/// ### with_hidden_files
///
/// Enable HIDDEN_FILES option /// Enable HIDDEN_FILES option
pub fn with_hidden_files(&mut self, val: bool) -> &mut FileExplorerBuilder { pub fn with_hidden_files(&mut self, val: bool) -> &mut FileExplorerBuilder {
if let Some(e) = self.explorer.as_mut() { if let Some(e) = self.explorer.as_mut() {
@@ -68,8 +60,6 @@ impl FileExplorerBuilder {
self self
} }
/// ### with_file_sorting
///
/// Set sorting method /// Set sorting method
pub fn with_file_sorting(&mut self, sorting: FileSorting) -> &mut FileExplorerBuilder { pub fn with_file_sorting(&mut self, sorting: FileSorting) -> &mut FileExplorerBuilder {
if let Some(e) = self.explorer.as_mut() { if let Some(e) = self.explorer.as_mut() {
@@ -78,8 +68,6 @@ impl FileExplorerBuilder {
self self
} }
/// ### with_dirs_first
///
/// Enable DIRS_FIRST option /// Enable DIRS_FIRST option
pub fn with_group_dirs(&mut self, group_dirs: Option<GroupDirs>) -> &mut FileExplorerBuilder { pub fn with_group_dirs(&mut self, group_dirs: Option<GroupDirs>) -> &mut FileExplorerBuilder {
if let Some(e) = self.explorer.as_mut() { if let Some(e) = self.explorer.as_mut() {
@@ -88,8 +76,6 @@ impl FileExplorerBuilder {
self self
} }
/// ### with_stack_size
///
/// Set stack size for FileExplorer /// Set stack size for FileExplorer
pub fn with_stack_size(&mut self, sz: usize) -> &mut FileExplorerBuilder { pub fn with_stack_size(&mut self, sz: usize) -> &mut FileExplorerBuilder {
if let Some(e) = self.explorer.as_mut() { if let Some(e) = self.explorer.as_mut() {
@@ -99,8 +85,6 @@ impl FileExplorerBuilder {
self self
} }
/// ### with_formatter
///
/// Set formatter for FileExplorer /// Set formatter for FileExplorer
pub fn with_formatter(&mut self, fmt_str: Option<&str>) -> &mut FileExplorerBuilder { pub fn with_formatter(&mut self, fmt_str: Option<&str>) -> &mut FileExplorerBuilder {
if let Some(e) = self.explorer.as_mut() { if let Some(e) = self.explorer.as_mut() {

View File

@@ -64,8 +64,6 @@ lazy_static! {
static ref FMT_ATTR_REGEX: Regex = Regex::new(r"(?:([A-Z]+))(:?([0-9]+))?(:?(.+))?").ok().unwrap(); static ref FMT_ATTR_REGEX: Regex = Regex::new(r"(?:([A-Z]+))(:?([0-9]+))?(:?(.+))?").ok().unwrap();
} }
/// ## CallChainBlock
///
/// Call Chain block is a block in a chain of functions which are called in order to format the Entry. /// Call Chain block is a block in a chain of functions which are called in order to format the Entry.
/// A callChain is instantiated starting from the Formatter syntax and the regex, once the groups are found /// A callChain is instantiated starting from the Formatter syntax and the regex, once the groups are found
/// a chain of function is made using the Formatters method. /// a chain of function is made using the Formatters method.
@@ -84,8 +82,6 @@ struct CallChainBlock {
} }
impl CallChainBlock { impl CallChainBlock {
/// ### new
///
/// Create a new `CallChainBlock` /// Create a new `CallChainBlock`
pub fn new( pub fn new(
func: FmtCallback, func: FmtCallback,
@@ -102,8 +98,6 @@ impl CallChainBlock {
} }
} }
/// ### next
///
/// Call next callback in the CallChain /// Call next callback in the CallChain
pub fn next(&self, fmt: &Formatter, fsentry: &Entry, cur_str: &str) -> String { pub fn next(&self, fmt: &Formatter, fsentry: &Entry, cur_str: &str) -> String {
// Call func // Call func
@@ -122,8 +116,6 @@ impl CallChainBlock {
} }
} }
/// ### push
///
/// Push func to the last element in the Call chain /// Push func to the last element in the Call chain
pub fn push( pub fn push(
&mut self, &mut self,
@@ -144,8 +136,6 @@ impl CallChainBlock {
} }
} }
/// ## Formatter
///
/// Formatter takes care of formatting FsEntries according to the provided keys. /// Formatter takes care of formatting FsEntries according to the provided keys.
/// Formatting is performed using the `CallChainBlock`, which composed makes a Call Chain. This method is extremely fast compared to match the format groups /// Formatting is performed using the `CallChainBlock`, which composed makes a Call Chain. This method is extremely fast compared to match the format groups
/// at each fmt call. /// at each fmt call.
@@ -154,8 +144,6 @@ pub struct Formatter {
} }
impl Default for Formatter { impl Default for Formatter {
/// ### default
///
/// Instantiates a Formatter with the default fmt syntax /// Instantiates a Formatter with the default fmt syntax
fn default() -> Self { fn default() -> Self {
Formatter { Formatter {
@@ -165,8 +153,6 @@ impl Default for Formatter {
} }
impl Formatter { impl Formatter {
/// ### new
///
/// Instantiates a new `Formatter` with the provided format string /// Instantiates a new `Formatter` with the provided format string
pub fn new(fmt_str: &str) -> Self { pub fn new(fmt_str: &str) -> Self {
Formatter { Formatter {
@@ -174,8 +160,6 @@ impl Formatter {
} }
} }
/// ### fmt
///
/// Format fsentry /// Format fsentry
pub fn fmt(&self, fsentry: &Entry) -> String { pub fn fmt(&self, fsentry: &Entry) -> String {
// Execute callchain blocks // Execute callchain blocks
@@ -184,8 +168,6 @@ impl Formatter {
// Fmt methods // Fmt methods
/// ### fmt_atime
///
/// Format last access time /// Format last access time
fn fmt_atime( fn fmt_atime(
&self, &self,
@@ -213,8 +195,6 @@ impl Formatter {
) )
} }
/// ### fmt_ctime
///
/// Format creation time /// Format creation time
fn fmt_ctime( fn fmt_ctime(
&self, &self,
@@ -242,8 +222,6 @@ impl Formatter {
) )
} }
/// ### fmt_group
///
/// Format owner group /// Format owner group
fn fmt_group( fn fmt_group(
&self, &self,
@@ -277,8 +255,6 @@ impl Formatter {
) )
} }
/// ### fmt_mtime
///
/// Format last change time /// Format last change time
fn fmt_mtime( fn fmt_mtime(
&self, &self,
@@ -306,8 +282,6 @@ impl Formatter {
) )
} }
/// ### fmt_name
///
/// Format file name /// Format file name
fn fmt_name( fn fmt_name(
&self, &self,
@@ -339,8 +313,6 @@ impl Formatter {
format!("{}{}{:0width$}", cur_str, prefix, name, width = file_len) format!("{}{}{:0width$}", cur_str, prefix, name, width = file_len)
} }
/// ### fmt_path
///
/// Format path /// Format path
fn fmt_path( fn fmt_path(
&self, &self,
@@ -366,8 +338,6 @@ impl Formatter {
) )
} }
/// ### fmt_pex
///
/// Format file permissions /// Format file permissions
fn fmt_pex( fn fmt_pex(
&self, &self,
@@ -403,8 +373,6 @@ impl Formatter {
format!("{}{}{:10}", cur_str, prefix, pex) format!("{}{}{:10}", cur_str, prefix, pex)
} }
/// ### fmt_size
///
/// Format file size /// Format file size
fn fmt_size( fn fmt_size(
&self, &self,
@@ -425,8 +393,6 @@ impl Formatter {
} }
} }
/// ### fmt_symlink
///
/// Format file symlink (if any) /// Format file symlink (if any)
fn fmt_symlink( fn fmt_symlink(
&self, &self,
@@ -454,8 +420,6 @@ impl Formatter {
} }
} }
/// ### fmt_user
///
/// Format owner user /// Format owner user
fn fmt_user( fn fmt_user(
&self, &self,
@@ -483,8 +447,6 @@ impl Formatter {
format!("{}{}{:12}", cur_str, prefix, username) format!("{}{}{:12}", cur_str, prefix, username)
} }
/// ### fmt_fallback
///
/// Fallback function in case the format key is unknown /// Fallback function in case the format key is unknown
/// It does nothing, just returns cur_str /// It does nothing, just returns cur_str
fn fmt_fallback( fn fmt_fallback(
@@ -501,8 +463,6 @@ impl Formatter {
// Static // Static
/// ### make_callchain
///
/// Make a callchain starting from the fmt str /// Make a callchain starting from the fmt str
fn make_callchain(fmt_str: &str) -> CallChainBlock { fn make_callchain(fmt_str: &str) -> CallChainBlock {
// Init chain block // Init chain block
@@ -952,8 +912,6 @@ mod tests {
assert_eq!(formatter.fmt(&entry).as_str(), "File path: c/bar.txt"); assert_eq!(formatter.fmt(&entry).as_str(), "File path: c/bar.txt");
} }
/// ### dummy_fmt
///
/// Dummy formatter, just yelds an 'A' at the end of the current string /// Dummy formatter, just yelds an 'A' at the end of the current string
fn dummy_fmt( fn dummy_fmt(
_fmt: &Formatter, _fmt: &Formatter,

View File

@@ -47,8 +47,6 @@ bitflags! {
} }
} }
/// ## FileSorting
///
/// FileSorting defines the criteria for sorting files /// FileSorting defines the criteria for sorting files
#[derive(Copy, Clone, PartialEq, std::fmt::Debug)] #[derive(Copy, Clone, PartialEq, std::fmt::Debug)]
pub enum FileSorting { pub enum FileSorting {
@@ -58,8 +56,6 @@ pub enum FileSorting {
Size, Size,
} }
/// ## GroupDirs
///
/// GroupDirs defines how directories should be grouped in sorting files /// GroupDirs defines how directories should be grouped in sorting files
#[derive(PartialEq, std::fmt::Debug)] #[derive(PartialEq, std::fmt::Debug)]
pub enum GroupDirs { pub enum GroupDirs {
@@ -67,8 +63,6 @@ pub enum GroupDirs {
Last, Last,
} }
/// ## FileExplorer
///
/// File explorer states /// File explorer states
pub struct FileExplorer { pub struct FileExplorer {
pub wrkdir: PathBuf, // Current directory pub wrkdir: PathBuf, // Current directory
@@ -97,8 +91,6 @@ impl Default for FileExplorer {
} }
impl FileExplorer { impl FileExplorer {
/// ### pushd
///
/// push directory to stack /// push directory to stack
pub fn pushd(&mut self, dir: &Path) { pub fn pushd(&mut self, dir: &Path) {
// Check if stack would overflow the size // Check if stack would overflow the size
@@ -109,15 +101,11 @@ impl FileExplorer {
self.dirstack.push_back(PathBuf::from(dir)); self.dirstack.push_back(PathBuf::from(dir));
} }
/// ### popd
///
/// Pop directory from the stack and return the directory /// Pop directory from the stack and return the directory
pub fn popd(&mut self) -> Option<PathBuf> { pub fn popd(&mut self) -> Option<PathBuf> {
self.dirstack.pop_back() self.dirstack.pop_back()
} }
/// ### set_files
///
/// Set Explorer files /// Set Explorer files
/// This method will also sort entries based on current options /// This method will also sort entries based on current options
/// Once all sorting have been performed, index is moved to first valid entry. /// Once all sorting have been performed, index is moved to first valid entry.
@@ -127,8 +115,6 @@ impl FileExplorer {
self.sort(); self.sort();
} }
/// ### del_entry
///
/// Delete file at provided index /// Delete file at provided index
pub fn del_entry(&mut self, idx: usize) { pub fn del_entry(&mut self, idx: usize) {
if self.files.len() > idx { if self.files.len() > idx {
@@ -137,16 +123,12 @@ impl FileExplorer {
} }
/* /*
/// ### count
///
/// Return amount of files /// Return amount of files
pub fn count(&self) -> usize { pub fn count(&self) -> usize {
self.files.len() self.files.len()
} }
*/ */
/// ### iter_files
///
/// Iterate over files /// Iterate over files
/// Filters are applied based on current options (e.g. hidden files not returned) /// Filters are applied based on current options (e.g. hidden files not returned)
pub fn iter_files(&self) -> impl Iterator<Item = &Entry> + '_ { pub fn iter_files(&self) -> impl Iterator<Item = &Entry> + '_ {
@@ -163,15 +145,11 @@ impl FileExplorer {
})) }))
} }
/// ### iter_files_all
///
/// Iterate all files; doesn't care about options /// Iterate all files; doesn't care about options
pub fn iter_files_all(&self) -> impl Iterator<Item = &Entry> + '_ { pub fn iter_files_all(&self) -> impl Iterator<Item = &Entry> + '_ {
Box::new(self.files.iter()) Box::new(self.files.iter())
} }
/// ### get
///
/// Get file at relative index /// Get file at relative index
pub fn get(&self, idx: usize) -> Option<&Entry> { pub fn get(&self, idx: usize) -> Option<&Entry> {
let opts: ExplorerOpts = self.opts; let opts: ExplorerOpts = self.opts;
@@ -193,8 +171,6 @@ impl FileExplorer {
// Formatting // Formatting
/// ### fmt_file
///
/// Format a file entry /// Format a file entry
pub fn fmt_file(&self, entry: &Entry) -> String { pub fn fmt_file(&self, entry: &Entry) -> String {
self.fmt.fmt(entry) self.fmt.fmt(entry)
@@ -202,8 +178,6 @@ impl FileExplorer {
// Sorting // Sorting
/// ### sort_by
///
/// Choose sorting method; then sort files /// Choose sorting method; then sort files
pub fn sort_by(&mut self, sorting: FileSorting) { pub fn sort_by(&mut self, sorting: FileSorting) {
// If method HAS ACTUALLY CHANGED, sort (performance!) // If method HAS ACTUALLY CHANGED, sort (performance!)
@@ -213,15 +187,11 @@ impl FileExplorer {
} }
} }
/// ### get_file_sorting
///
/// Get current file sorting method /// Get current file sorting method
pub fn get_file_sorting(&self) -> FileSorting { pub fn get_file_sorting(&self) -> FileSorting {
self.file_sorting self.file_sorting
} }
/// ### group_dirs_by
///
/// Choose group dirs method; then sort files /// Choose group dirs method; then sort files
pub fn group_dirs_by(&mut self, group_dirs: Option<GroupDirs>) { pub fn group_dirs_by(&mut self, group_dirs: Option<GroupDirs>) {
// If method HAS ACTUALLY CHANGED, sort (performance!) // If method HAS ACTUALLY CHANGED, sort (performance!)
@@ -231,8 +201,6 @@ impl FileExplorer {
} }
} }
/// ### sort
///
/// Sort files based on Explorer options. /// Sort files based on Explorer options.
fn sort(&mut self) { fn sort(&mut self) {
// Choose sorting method // Choose sorting method
@@ -252,60 +220,44 @@ impl FileExplorer {
} }
} }
/// ### sort_files_by_name
///
/// Sort explorer files by their name. All names are converted to lowercase /// Sort explorer files by their name. All names are converted to lowercase
fn sort_files_by_name(&mut self) { fn sort_files_by_name(&mut self) {
self.files.sort_by_key(|x: &Entry| x.name().to_lowercase()); self.files.sort_by_key(|x: &Entry| x.name().to_lowercase());
} }
/// ### sort_files_by_mtime
///
/// Sort files by mtime; the newest comes first /// Sort files by mtime; the newest comes first
fn sort_files_by_mtime(&mut self) { fn sort_files_by_mtime(&mut self) {
self.files self.files
.sort_by(|a: &Entry, b: &Entry| b.metadata().mtime.cmp(&a.metadata().mtime)); .sort_by(|a: &Entry, b: &Entry| b.metadata().mtime.cmp(&a.metadata().mtime));
} }
/// ### sort_files_by_creation_time
///
/// Sort files by creation time; the newest comes first /// Sort files by creation time; the newest comes first
fn sort_files_by_creation_time(&mut self) { fn sort_files_by_creation_time(&mut self) {
self.files self.files
.sort_by_key(|b: &Entry| Reverse(b.metadata().ctime)); .sort_by_key(|b: &Entry| Reverse(b.metadata().ctime));
} }
/// ### sort_files_by_size
///
/// Sort files by size /// Sort files by size
fn sort_files_by_size(&mut self) { fn sort_files_by_size(&mut self) {
self.files self.files
.sort_by_key(|b: &Entry| Reverse(b.metadata().size)); .sort_by_key(|b: &Entry| Reverse(b.metadata().size));
} }
/// ### sort_files_directories_first
///
/// Sort files; directories come first /// Sort files; directories come first
fn sort_files_directories_first(&mut self) { fn sort_files_directories_first(&mut self) {
self.files.sort_by_key(|x: &Entry| x.is_file()); self.files.sort_by_key(|x: &Entry| x.is_file());
} }
/// ### sort_files_directories_last
///
/// Sort files; directories come last /// Sort files; directories come last
fn sort_files_directories_last(&mut self) { fn sort_files_directories_last(&mut self) {
self.files.sort_by_key(|x: &Entry| x.is_dir()); self.files.sort_by_key(|x: &Entry| x.is_dir());
} }
/// ### toggle_hidden_files
///
/// Enable/disable hidden files /// Enable/disable hidden files
pub fn toggle_hidden_files(&mut self) { pub fn toggle_hidden_files(&mut self) {
self.opts.toggle(ExplorerOpts::SHOW_HIDDEN_FILES); self.opts.toggle(ExplorerOpts::SHOW_HIDDEN_FILES);
} }
/// ### hidden_files_visible
///
/// Returns whether hidden files are visible /// Returns whether hidden files are visible
pub fn hidden_files_visible(&self) -> bool { pub fn hidden_files_visible(&self) -> bool {
self.opts.intersects(ExplorerOpts::SHOW_HIDDEN_FILES) self.opts.intersects(ExplorerOpts::SHOW_HIDDEN_FILES)

View File

@@ -32,8 +32,6 @@ pub mod params;
pub use builder::Builder; pub use builder::Builder;
pub use params::{FileTransferParams, ProtocolParams}; pub use params::{FileTransferParams, ProtocolParams};
/// ## FileTransferProtocol
///
/// This enum defines the different transfer protocol available in termscp /// This enum defines the different transfer protocol available in termscp
#[derive(PartialEq, Debug, Clone, Copy)] #[derive(PartialEq, Debug, Clone, Copy)]

View File

@@ -39,8 +39,6 @@ pub struct FileTransferParams {
pub entry_directory: Option<PathBuf>, pub entry_directory: Option<PathBuf>,
} }
/// ## ProtocolParams
///
/// Container for protocol params /// Container for protocol params
#[derive(Debug, Clone)] #[derive(Debug, Clone)]
pub enum ProtocolParams { pub enum ProtocolParams {
@@ -48,8 +46,6 @@ pub enum ProtocolParams {
AwsS3(AwsS3Params), AwsS3(AwsS3Params),
} }
/// ## GenericProtocolParams
///
/// Protocol params used by most common protocols /// Protocol params used by most common protocols
#[derive(Debug, Clone)] #[derive(Debug, Clone)]
pub struct GenericProtocolParams { pub struct GenericProtocolParams {
@@ -59,8 +55,6 @@ pub struct GenericProtocolParams {
pub password: Option<String>, pub password: Option<String>,
} }
/// ## AwsS3Params
///
/// Connection parameters for AWS S3 protocol /// Connection parameters for AWS S3 protocol
#[derive(Debug, Clone)] #[derive(Debug, Clone)]
pub struct AwsS3Params { pub struct AwsS3Params {
@@ -70,8 +64,6 @@ pub struct AwsS3Params {
} }
impl FileTransferParams { impl FileTransferParams {
/// ### new
///
/// Instantiates a new `FileTransferParams` /// Instantiates a new `FileTransferParams`
pub fn new(protocol: FileTransferProtocol, params: ProtocolParams) -> Self { pub fn new(protocol: FileTransferProtocol, params: ProtocolParams) -> Self {
Self { Self {
@@ -81,8 +73,6 @@ impl FileTransferParams {
} }
} }
/// ### entry_directory
///
/// Set entry directory /// Set entry directory
pub fn entry_directory<P: AsRef<Path>>(mut self, dir: Option<P>) -> Self { pub fn entry_directory<P: AsRef<Path>>(mut self, dir: Option<P>) -> Self {
self.entry_directory = dir.map(|x| x.as_ref().to_path_buf()); self.entry_directory = dir.map(|x| x.as_ref().to_path_buf());
@@ -143,32 +133,24 @@ impl Default for GenericProtocolParams {
} }
impl GenericProtocolParams { impl GenericProtocolParams {
/// ### address
///
/// Set address to params /// Set address to params
pub fn address<S: AsRef<str>>(mut self, address: S) -> Self { pub fn address<S: AsRef<str>>(mut self, address: S) -> Self {
self.address = address.as_ref().to_string(); self.address = address.as_ref().to_string();
self self
} }
/// ### port
///
/// Set port to params /// Set port to params
pub fn port(mut self, port: u16) -> Self { pub fn port(mut self, port: u16) -> Self {
self.port = port; self.port = port;
self self
} }
/// ### username
///
/// Set username for params /// Set username for params
pub fn username<S: AsRef<str>>(mut self, username: Option<S>) -> Self { pub fn username<S: AsRef<str>>(mut self, username: Option<S>) -> Self {
self.username = username.map(|x| x.as_ref().to_string()); self.username = username.map(|x| x.as_ref().to_string());
self self
} }
/// ### password
///
/// Set password for params /// Set password for params
pub fn password<S: AsRef<str>>(mut self, password: Option<S>) -> Self { pub fn password<S: AsRef<str>>(mut self, password: Option<S>) -> Self {
self.password = password.map(|x| x.as_ref().to_string()); self.password = password.map(|x| x.as_ref().to_string());
@@ -179,8 +161,6 @@ impl GenericProtocolParams {
// -- S3 params // -- S3 params
impl AwsS3Params { impl AwsS3Params {
/// ### new
///
/// Instantiates a new `AwsS3Params` struct /// Instantiates a new `AwsS3Params` struct
pub fn new<S: AsRef<str>>(bucket: S, region: S, profile: Option<S>) -> Self { pub fn new<S: AsRef<str>>(bucket: S, region: S, profile: Option<S>) -> Self {
Self { Self {

View File

@@ -43,8 +43,6 @@ use std::os::unix::fs::{MetadataExt, PermissionsExt};
// Locals // Locals
use crate::utils::path; use crate::utils::path;
/// ## HostErrorType
///
/// HostErrorType provides an overview of the specific host error /// HostErrorType provides an overview of the specific host error
#[derive(Error, Debug)] #[derive(Error, Debug)]
pub enum HostErrorType { pub enum HostErrorType {
@@ -77,8 +75,6 @@ pub struct HostError {
} }
impl HostError { impl HostError {
/// ### new
///
/// Instantiates a new HostError /// Instantiates a new HostError
pub(crate) fn new(error: HostErrorType, errno: Option<std::io::Error>, p: &Path) -> Self { pub(crate) fn new(error: HostErrorType, errno: Option<std::io::Error>, p: &Path) -> Self {
HostError { HostError {
@@ -112,8 +108,6 @@ impl std::fmt::Display for HostError {
} }
} }
/// ## Localhost
///
/// Localhost is the entity which holds the information about the current directory and host. /// Localhost is the entity which holds the information about the current directory and host.
/// It provides functions to navigate across the local host file system /// It provides functions to navigate across the local host file system
pub struct Localhost { pub struct Localhost {
@@ -122,8 +116,6 @@ pub struct Localhost {
} }
impl Localhost { impl Localhost {
/// ### new
///
/// Instantiates a new Localhost struct /// Instantiates a new Localhost struct
pub fn new(wrkdir: PathBuf) -> Result<Localhost, HostError> { pub fn new(wrkdir: PathBuf) -> Result<Localhost, HostError> {
debug!("Initializing localhost at {}", wrkdir.display()); debug!("Initializing localhost at {}", wrkdir.display());
@@ -158,23 +150,17 @@ impl Localhost {
Ok(host) Ok(host)
} }
/// ### pwd
///
/// Print working directory /// Print working directory
pub fn pwd(&self) -> PathBuf { pub fn pwd(&self) -> PathBuf {
self.wrkdir.clone() self.wrkdir.clone()
} }
/// ### list_dir
///
/// List files in current directory /// List files in current directory
#[allow(dead_code)] #[allow(dead_code)]
pub fn list_dir(&self) -> Vec<Entry> { pub fn list_dir(&self) -> Vec<Entry> {
self.files.clone() self.files.clone()
} }
/// ### change_wrkdir
///
/// Change working directory with the new provided directory /// Change working directory with the new provided directory
pub fn change_wrkdir(&mut self, new_dir: &Path) -> Result<PathBuf, HostError> { pub fn change_wrkdir(&mut self, new_dir: &Path) -> Result<PathBuf, HostError> {
let new_dir: PathBuf = self.to_path(new_dir); let new_dir: PathBuf = self.to_path(new_dir);
@@ -215,15 +201,11 @@ impl Localhost {
Ok(self.wrkdir.clone()) Ok(self.wrkdir.clone())
} }
/// ### mkdir
///
/// Make a directory at path and update the file list (only if relative) /// Make a directory at path and update the file list (only if relative)
pub fn mkdir(&mut self, dir_name: &Path) -> Result<(), HostError> { pub fn mkdir(&mut self, dir_name: &Path) -> Result<(), HostError> {
self.mkdir_ex(dir_name, false) self.mkdir_ex(dir_name, false)
} }
/// ### mkdir_ex
///
/// Extended option version of makedir. /// Extended option version of makedir.
/// ignex: don't report error if directory already exists /// ignex: don't report error if directory already exists
pub fn mkdir_ex(&mut self, dir_name: &Path, ignex: bool) -> Result<(), HostError> { pub fn mkdir_ex(&mut self, dir_name: &Path, ignex: bool) -> Result<(), HostError> {
@@ -262,8 +244,6 @@ impl Localhost {
} }
} }
/// ### remove
///
/// Remove file entry /// Remove file entry
pub fn remove(&mut self, entry: &Entry) -> Result<(), HostError> { pub fn remove(&mut self, entry: &Entry) -> Result<(), HostError> {
match entry { match entry {
@@ -328,8 +308,6 @@ impl Localhost {
} }
} }
/// ### rename
///
/// Rename file or directory to new name /// Rename file or directory to new name
pub fn rename(&mut self, entry: &Entry, dst_path: &Path) -> Result<(), HostError> { pub fn rename(&mut self, entry: &Entry, dst_path: &Path) -> Result<(), HostError> {
match std::fs::rename(entry.path(), dst_path) { match std::fs::rename(entry.path(), dst_path) {
@@ -359,8 +337,6 @@ impl Localhost {
} }
} }
/// ### copy
///
/// Copy file to destination path /// Copy file to destination path
pub fn copy(&mut self, entry: &Entry, dst: &Path) -> Result<(), HostError> { pub fn copy(&mut self, entry: &Entry, dst: &Path) -> Result<(), HostError> {
// Get absolute path of dest // Get absolute path of dest
@@ -436,8 +412,6 @@ impl Localhost {
Ok(()) Ok(())
} }
/// ### stat
///
/// Stat file and create a Entry /// Stat file and create a Entry
#[cfg(target_family = "unix")] #[cfg(target_family = "unix")]
pub fn stat(&self, path: &Path) -> Result<Entry, HostError> { pub fn stat(&self, path: &Path) -> Result<Entry, HostError> {
@@ -491,8 +465,6 @@ impl Localhost {
}) })
} }
/// ### stat
///
/// Stat file and create a Entry /// Stat file and create a Entry
#[cfg(target_os = "windows")] #[cfg(target_os = "windows")]
pub fn stat(&self, path: &Path) -> Result<Entry, HostError> { pub fn stat(&self, path: &Path) -> Result<Entry, HostError> {
@@ -542,8 +514,6 @@ impl Localhost {
}) })
} }
/// ### exec
///
/// Execute a command on localhost /// Execute a command on localhost
pub fn exec(&self, cmd: &str) -> Result<String, HostError> { pub fn exec(&self, cmd: &str) -> Result<String, HostError> {
// Make command // Make command
@@ -570,8 +540,6 @@ impl Localhost {
} }
} }
/// ### chmod
///
/// Change file mode to file, according to UNIX permissions /// Change file mode to file, according to UNIX permissions
#[cfg(target_family = "unix")] #[cfg(target_family = "unix")]
pub fn chmod(&self, path: &Path, pex: UnixPex) -> Result<(), HostError> { pub fn chmod(&self, path: &Path, pex: UnixPex) -> Result<(), HostError> {
@@ -611,8 +579,6 @@ impl Localhost {
} }
} }
/// ### open_file_read
///
/// Open file for read /// Open file for read
pub fn open_file_read(&self, file: &Path) -> Result<StdFile, HostError> { pub fn open_file_read(&self, file: &Path) -> Result<StdFile, HostError> {
let file: PathBuf = self.to_path(file); let file: PathBuf = self.to_path(file);
@@ -643,8 +609,6 @@ impl Localhost {
} }
} }
/// ### open_file_write
///
/// Open file for write /// Open file for write
pub fn open_file_write(&self, file: &Path) -> Result<StdFile, HostError> { pub fn open_file_write(&self, file: &Path) -> Result<StdFile, HostError> {
let file: PathBuf = self.to_path(file); let file: PathBuf = self.to_path(file);
@@ -674,15 +638,11 @@ impl Localhost {
} }
} }
/// ### file_exists
///
/// Returns whether provided file path exists /// Returns whether provided file path exists
pub fn file_exists(&self, path: &Path) -> bool { pub fn file_exists(&self, path: &Path) -> bool {
path.exists() path.exists()
} }
/// ### scan_dir
///
/// Get content of the current directory as a list of fs entry /// Get content of the current directory as a list of fs entry
pub fn scan_dir(&self, dir: &Path) -> Result<Vec<Entry>, HostError> { pub fn scan_dir(&self, dir: &Path) -> Result<Vec<Entry>, HostError> {
info!("Reading directory {}", dir.display()); info!("Reading directory {}", dir.display());
@@ -706,8 +666,6 @@ impl Localhost {
} }
} }
/// ### find
///
/// Find files matching `search` on localhost starting from current directory. Search supports recursive search of course. /// Find files matching `search` on localhost starting from current directory. Search supports recursive search of course.
/// The `search` argument supports wilcards ('*', '?') /// The `search` argument supports wilcards ('*', '?')
pub fn find(&self, search: &str) -> Result<Vec<Entry>, HostError> { pub fn find(&self, search: &str) -> Result<Vec<Entry>, HostError> {
@@ -716,8 +674,6 @@ impl Localhost {
// -- privates // -- privates
/// ### iter_search
///
/// Recursive call for `find` method. /// Recursive call for `find` method.
/// Search in current directory for files which match `filter`. /// Search in current directory for files which match `filter`.
/// If a directory is found in current directory, `iter_search` will be called using that dir as argument. /// If a directory is found in current directory, `iter_search` will be called using that dir as argument.
@@ -755,8 +711,6 @@ impl Localhost {
} }
} }
/// ### to_path
///
/// Convert path to absolute path /// Convert path to absolute path
fn to_path(&self, p: &Path) -> PathBuf { fn to_path(&self, p: &Path) -> PathBuf {
path::absolutize(self.wrkdir.as_path(), p) path::absolutize(self.wrkdir.as_path(), p)

View File

@@ -44,8 +44,6 @@ pub enum UpdateStatus {
UpdateInstalled(String), UpdateInstalled(String),
} }
/// ## Release
///
/// Info related to a github release /// Info related to a github release
#[derive(Debug)] #[derive(Debug)]
pub struct Release { pub struct Release {
@@ -53,8 +51,6 @@ pub struct Release {
pub body: String, pub body: String,
} }
/// ## Update
///
/// The update structure defines the options used to install the update. /// The update structure defines the options used to install the update.
/// Once you're fine with the options, just call the `upgrade()` method to upgrade termscp. /// Once you're fine with the options, just call the `upgrade()` method to upgrade termscp.
#[derive(Debug, Default)] #[derive(Debug, Default)]
@@ -64,16 +60,12 @@ pub struct Update {
} }
impl Update { impl Update {
/// ### show_progress
///
/// Set whether to show or not the progress bar /// Set whether to show or not the progress bar
pub fn show_progress(mut self, opt: bool) -> Self { pub fn show_progress(mut self, opt: bool) -> Self {
self.progress = opt; self.progress = opt;
self self
} }
/// ### ask_confirm
///
/// Set whether to ask for confirm when updating /// Set whether to ask for confirm when updating
pub fn ask_confirm(mut self, opt: bool) -> Self { pub fn ask_confirm(mut self, opt: bool) -> Self {
self.ask_confirm = opt; self.ask_confirm = opt;
@@ -96,8 +88,6 @@ impl Update {
.map(UpdateStatus::from) .map(UpdateStatus::from)
} }
/// ### is_new_version_available
///
/// Returns whether a new version of termscp is available /// Returns whether a new version of termscp is available
/// In case of success returns Ok(Option<Release>), where the Option is Some(new_version); /// In case of success returns Ok(Option<Release>), where the Option is Some(new_version);
/// otherwise if no version is available, return None /// otherwise if no version is available, return None
@@ -119,8 +109,6 @@ impl Update {
.map(Self::check_version) .map(Self::check_version)
} }
/// ### check_version
///
/// In case received version is newer than current one, version as Some is returned; otherwise None /// In case received version is newer than current one, version as Some is returned; otherwise None
fn check_version(r: Release) -> Option<Release> { fn check_version(r: Release) -> Option<Release> {
match parse_semver(r.version.as_str()) { match parse_semver(r.version.as_str()) {

View File

@@ -44,8 +44,6 @@ use std::path::{Path, PathBuf};
use std::string::ToString; use std::string::ToString;
use std::time::SystemTime; use std::time::SystemTime;
/// ## BookmarksClient
///
/// BookmarksClient provides a layer between the host system and the bookmarks module /// BookmarksClient provides a layer between the host system and the bookmarks module
pub struct BookmarksClient { pub struct BookmarksClient {
hosts: UserHosts, hosts: UserHosts,
@@ -55,8 +53,6 @@ pub struct BookmarksClient {
} }
impl BookmarksClient { impl BookmarksClient {
/// ### BookmarksClient
///
/// Instantiates a new BookmarksClient /// Instantiates a new BookmarksClient
/// Bookmarks file path must be provided /// Bookmarks file path must be provided
/// Storage path for file provider must be provided /// Storage path for file provider must be provided
@@ -155,15 +151,11 @@ impl BookmarksClient {
Ok(client) Ok(client)
} }
/// ### iter_bookmarks
///
/// Iterate over bookmarks keys /// Iterate over bookmarks keys
pub fn iter_bookmarks(&self) -> impl Iterator<Item = &String> + '_ { pub fn iter_bookmarks(&self) -> impl Iterator<Item = &String> + '_ {
Box::new(self.hosts.bookmarks.keys()) Box::new(self.hosts.bookmarks.keys())
} }
/// ### get_bookmark
///
/// Get bookmark associated to key /// Get bookmark associated to key
pub fn get_bookmark(&self, key: &str) -> Option<FileTransferParams> { pub fn get_bookmark(&self, key: &str) -> Option<FileTransferParams> {
debug!("Getting bookmark {}", key); debug!("Getting bookmark {}", key);
@@ -183,8 +175,6 @@ impl BookmarksClient {
Some(FileTransferParams::from(entry)) Some(FileTransferParams::from(entry))
} }
/// ### add_recent
///
/// Add a new recent to bookmarks /// Add a new recent to bookmarks
pub fn add_bookmark<S: AsRef<str>>( pub fn add_bookmark<S: AsRef<str>>(
&mut self, &mut self,
@@ -207,22 +197,16 @@ impl BookmarksClient {
self.hosts.bookmarks.insert(name, host); self.hosts.bookmarks.insert(name, host);
} }
/// ### del_bookmark
///
/// Delete entry from bookmarks /// Delete entry from bookmarks
pub fn del_bookmark(&mut self, name: &str) { pub fn del_bookmark(&mut self, name: &str) {
let _ = self.hosts.bookmarks.remove(name); let _ = self.hosts.bookmarks.remove(name);
info!("Removed bookmark {}", name); info!("Removed bookmark {}", name);
} }
/// ### iter_recents
///
/// Iterate over recents keys /// Iterate over recents keys
pub fn iter_recents(&self) -> impl Iterator<Item = &String> + '_ { pub fn iter_recents(&self) -> impl Iterator<Item = &String> + '_ {
Box::new(self.hosts.recents.keys()) Box::new(self.hosts.recents.keys())
} }
/// ### get_recent
///
/// Get recent associated to key /// Get recent associated to key
pub fn get_recent(&self, key: &str) -> Option<FileTransferParams> { pub fn get_recent(&self, key: &str) -> Option<FileTransferParams> {
// NOTE: password is not decrypted; recents will never have password // NOTE: password is not decrypted; recents will never have password
@@ -231,8 +215,6 @@ impl BookmarksClient {
Some(FileTransferParams::from(entry)) Some(FileTransferParams::from(entry))
} }
/// ### add_recent
///
/// Add a new recent to bookmarks /// Add a new recent to bookmarks
pub fn add_recent(&mut self, params: FileTransferParams) { pub fn add_recent(&mut self, params: FileTransferParams) {
// Make bookmark // Make bookmark
@@ -271,16 +253,12 @@ impl BookmarksClient {
self.hosts.recents.insert(name, host); self.hosts.recents.insert(name, host);
} }
/// ### del_recent
///
/// Delete entry from recents /// Delete entry from recents
pub fn del_recent(&mut self, name: &str) { pub fn del_recent(&mut self, name: &str) {
let _ = self.hosts.recents.remove(name); let _ = self.hosts.recents.remove(name);
info!("Removed recent host {}", name); info!("Removed recent host {}", name);
} }
/// ### write_bookmarks
///
/// Write bookmarks to file /// Write bookmarks to file
pub fn write_bookmarks(&self) -> Result<(), SerializerError> { pub fn write_bookmarks(&self) -> Result<(), SerializerError> {
// Open file // Open file
@@ -302,8 +280,6 @@ impl BookmarksClient {
} }
} }
/// ### read_bookmarks
///
/// Read bookmarks from file /// Read bookmarks from file
fn read_bookmarks(&mut self) -> Result<(), SerializerError> { fn read_bookmarks(&mut self) -> Result<(), SerializerError> {
// Open bookmarks file for read // Open bookmarks file for read
@@ -332,16 +308,12 @@ impl BookmarksClient {
} }
} }
/// ### generate_key
///
/// Generate a new AES key /// Generate a new AES key
fn generate_key() -> String { fn generate_key() -> String {
// Generate 256 bytes (2048 bits) key // Generate 256 bytes (2048 bits) key
random_alphanumeric_with_len(256) random_alphanumeric_with_len(256)
} }
/// ### make_bookmark
///
/// Make bookmark from credentials /// Make bookmark from credentials
fn make_bookmark(&self, params: FileTransferParams) -> Bookmark { fn make_bookmark(&self, params: FileTransferParams) -> Bookmark {
let mut bookmark: Bookmark = Bookmark::from(params); let mut bookmark: Bookmark = Bookmark::from(params);
@@ -352,15 +324,11 @@ impl BookmarksClient {
bookmark bookmark
} }
/// ### encrypt_str
///
/// Encrypt provided string using AES-128. Encrypted buffer is then converted to BASE64 /// Encrypt provided string using AES-128. Encrypted buffer is then converted to BASE64
fn encrypt_str(&self, txt: &str) -> String { fn encrypt_str(&self, txt: &str) -> String {
crypto::aes128_b64_crypt(self.key.as_str(), txt) crypto::aes128_b64_crypt(self.key.as_str(), txt)
} }
/// ### decrypt_str
///
/// Decrypt provided string using AES-128 /// Decrypt provided string using AES-128
fn decrypt_str(&self, secret: &str) -> Result<String, SerializerError> { fn decrypt_str(&self, secret: &str) -> Result<String, SerializerError> {
match crypto::aes128_b64_decrypt(self.key.as_str(), secret) { match crypto::aes128_b64_decrypt(self.key.as_str(), secret) {
@@ -741,8 +709,6 @@ mod tests {
assert!(client.decrypt_str("bidoof").is_err()); assert!(client.decrypt_str("bidoof").is_err());
} }
/// ### get_paths
///
/// Get paths for configuration and key for bookmarks /// Get paths for configuration and key for bookmarks
fn get_paths(dir: &Path) -> (PathBuf, PathBuf) { fn get_paths(dir: &Path) -> (PathBuf, PathBuf) {
let k: PathBuf = PathBuf::from(dir); let k: PathBuf = PathBuf::from(dir);

View File

@@ -42,8 +42,6 @@ use std::string::ToString;
// Types // Types
pub type SshHost = (String, String, PathBuf); // 0: host, 1: username, 2: RSA key path pub type SshHost = (String, String, PathBuf); // 0: host, 1: username, 2: RSA key path
/// ## ConfigClient
///
/// ConfigClient provides a high level API to communicate with the termscp configuration /// ConfigClient provides a high level API to communicate with the termscp configuration
pub struct ConfigClient { pub struct ConfigClient {
config: UserConfig, // Configuration loaded config: UserConfig, // Configuration loaded
@@ -53,8 +51,6 @@ pub struct ConfigClient {
} }
impl ConfigClient { impl ConfigClient {
/// ### new
///
/// Instantiate a new `ConfigClient` with provided path /// Instantiate a new `ConfigClient` with provided path
pub fn new(config_path: &Path, ssh_key_dir: &Path) -> Result<Self, SerializerError> { pub fn new(config_path: &Path, ssh_key_dir: &Path) -> Result<Self, SerializerError> {
// Initialize a default configuration // Initialize a default configuration
@@ -104,8 +100,6 @@ impl ConfigClient {
Ok(client) Ok(client)
} }
/// ### degraded
///
/// Instantiate a ConfigClient in degraded mode. /// Instantiate a ConfigClient in degraded mode.
/// When in degraded mode, the configuration in use will be the default configuration /// When in degraded mode, the configuration in use will be the default configuration
/// and the IO operation on configuration won't be available /// and the IO operation on configuration won't be available
@@ -120,15 +114,11 @@ impl ConfigClient {
// Text editor // Text editor
/// ### get_text_editor
///
/// Get text editor from configuration /// Get text editor from configuration
pub fn get_text_editor(&self) -> PathBuf { pub fn get_text_editor(&self) -> PathBuf {
self.config.user_interface.text_editor.clone() self.config.user_interface.text_editor.clone()
} }
/// ### set_text_editor
///
/// Set text editor path /// Set text editor path
pub fn set_text_editor(&mut self, path: PathBuf) { pub fn set_text_editor(&mut self, path: PathBuf) {
self.config.user_interface.text_editor = path; self.config.user_interface.text_editor = path;
@@ -136,8 +126,6 @@ impl ConfigClient {
// Default protocol // Default protocol
/// ### get_default_protocol
///
/// Get default protocol from configuration /// Get default protocol from configuration
pub fn get_default_protocol(&self) -> FileTransferProtocol { pub fn get_default_protocol(&self) -> FileTransferProtocol {
match FileTransferProtocol::from_str(self.config.user_interface.default_protocol.as_str()) { match FileTransferProtocol::from_str(self.config.user_interface.default_protocol.as_str()) {
@@ -146,43 +134,31 @@ impl ConfigClient {
} }
} }
/// ### set_default_protocol
///
/// Set default protocol to configuration /// Set default protocol to configuration
pub fn set_default_protocol(&mut self, proto: FileTransferProtocol) { pub fn set_default_protocol(&mut self, proto: FileTransferProtocol) {
self.config.user_interface.default_protocol = proto.to_string(); self.config.user_interface.default_protocol = proto.to_string();
} }
/// ### get_show_hidden_files
///
/// Get value of `show_hidden_files` /// Get value of `show_hidden_files`
pub fn get_show_hidden_files(&self) -> bool { pub fn get_show_hidden_files(&self) -> bool {
self.config.user_interface.show_hidden_files self.config.user_interface.show_hidden_files
} }
/// ### set_show_hidden_files
///
/// Set new value for `show_hidden_files` /// Set new value for `show_hidden_files`
pub fn set_show_hidden_files(&mut self, value: bool) { pub fn set_show_hidden_files(&mut self, value: bool) {
self.config.user_interface.show_hidden_files = value; self.config.user_interface.show_hidden_files = value;
} }
/// ### get_check_for_updates
///
/// Get value of `check_for_updates` /// Get value of `check_for_updates`
pub fn get_check_for_updates(&self) -> bool { pub fn get_check_for_updates(&self) -> bool {
self.config.user_interface.check_for_updates.unwrap_or(true) self.config.user_interface.check_for_updates.unwrap_or(true)
} }
/// ### set_check_for_updates
///
/// Set new value for `check_for_updates` /// Set new value for `check_for_updates`
pub fn set_check_for_updates(&mut self, value: bool) { pub fn set_check_for_updates(&mut self, value: bool) {
self.config.user_interface.check_for_updates = Some(value); self.config.user_interface.check_for_updates = Some(value);
} }
/// ### get_prompt_on_file_replace
///
/// Get value of `prompt_on_file_replace` /// Get value of `prompt_on_file_replace`
pub fn get_prompt_on_file_replace(&self) -> bool { pub fn get_prompt_on_file_replace(&self) -> bool {
self.config self.config
@@ -191,15 +167,11 @@ impl ConfigClient {
.unwrap_or(true) .unwrap_or(true)
} }
/// ### set_prompt_on_file_replace
///
/// Set new value for `prompt_on_file_replace` /// Set new value for `prompt_on_file_replace`
pub fn set_prompt_on_file_replace(&mut self, value: bool) { pub fn set_prompt_on_file_replace(&mut self, value: bool) {
self.config.user_interface.prompt_on_file_replace = Some(value); self.config.user_interface.prompt_on_file_replace = Some(value);
} }
/// ### get_group_dirs
///
/// Get GroupDirs value from configuration (will be converted from string) /// Get GroupDirs value from configuration (will be converted from string)
pub fn get_group_dirs(&self) -> Option<GroupDirs> { pub fn get_group_dirs(&self) -> Option<GroupDirs> {
// Convert string to `GroupDirs` // Convert string to `GroupDirs`
@@ -212,23 +184,17 @@ impl ConfigClient {
} }
} }
/// ### set_group_dirs
///
/// Set value for group_dir in configuration. /// Set value for group_dir in configuration.
/// Provided value, if `Some` will be converted to `GroupDirs` /// Provided value, if `Some` will be converted to `GroupDirs`
pub fn set_group_dirs(&mut self, val: Option<GroupDirs>) { pub fn set_group_dirs(&mut self, val: Option<GroupDirs>) {
self.config.user_interface.group_dirs = val.map(|val| val.to_string()); self.config.user_interface.group_dirs = val.map(|val| val.to_string());
} }
/// ### get_local_file_fmt
///
/// Get current file fmt for local host /// Get current file fmt for local host
pub fn get_local_file_fmt(&self) -> Option<String> { pub fn get_local_file_fmt(&self) -> Option<String> {
self.config.user_interface.file_fmt.clone() self.config.user_interface.file_fmt.clone()
} }
/// ### set_local_file_fmt
///
/// Set file fmt parameter for local host /// Set file fmt parameter for local host
pub fn set_local_file_fmt(&mut self, s: String) { pub fn set_local_file_fmt(&mut self, s: String) {
self.config.user_interface.file_fmt = match s.is_empty() { self.config.user_interface.file_fmt = match s.is_empty() {
@@ -237,15 +203,11 @@ impl ConfigClient {
}; };
} }
/// ### get_remote_file_fmt
///
/// Get current file fmt for remote host /// Get current file fmt for remote host
pub fn get_remote_file_fmt(&self) -> Option<String> { pub fn get_remote_file_fmt(&self) -> Option<String> {
self.config.user_interface.remote_file_fmt.clone() self.config.user_interface.remote_file_fmt.clone()
} }
/// ### set_remote_file_fmt
///
/// Set file fmt parameter for remote host /// Set file fmt parameter for remote host
pub fn set_remote_file_fmt(&mut self, s: String) { pub fn set_remote_file_fmt(&mut self, s: String) {
self.config.user_interface.remote_file_fmt = match s.is_empty() { self.config.user_interface.remote_file_fmt = match s.is_empty() {
@@ -254,22 +216,16 @@ impl ConfigClient {
}; };
} }
/// ### get_notifications
///
/// Get value of `notifications` /// Get value of `notifications`
pub fn get_notifications(&self) -> bool { pub fn get_notifications(&self) -> bool {
self.config.user_interface.notifications.unwrap_or(true) self.config.user_interface.notifications.unwrap_or(true)
} }
/// ### set_notifications
///
/// Set new value for `notifications` /// Set new value for `notifications`
pub fn set_notifications(&mut self, value: bool) { pub fn set_notifications(&mut self, value: bool) {
self.config.user_interface.notifications = Some(value); self.config.user_interface.notifications = Some(value);
} }
/// ### get_notification_threshold
///
/// Get value of `notification_threshold` /// Get value of `notification_threshold`
pub fn get_notification_threshold(&self) -> u64 { pub fn get_notification_threshold(&self) -> u64 {
self.config self.config
@@ -278,8 +234,6 @@ impl ConfigClient {
.unwrap_or(DEFAULT_NOTIFICATION_TRANSFER_THRESHOLD) .unwrap_or(DEFAULT_NOTIFICATION_TRANSFER_THRESHOLD)
} }
/// ### set_notification_threshold
///
/// Set new value for `notification_threshold` /// Set new value for `notification_threshold`
pub fn set_notification_threshold(&mut self, value: u64) { pub fn set_notification_threshold(&mut self, value: u64) {
self.config.user_interface.notification_threshold = Some(value); self.config.user_interface.notification_threshold = Some(value);
@@ -287,8 +241,6 @@ impl ConfigClient {
// SSH Keys // SSH Keys
/// ### save_ssh_key
///
/// Save a SSH key into configuration. /// Save a SSH key into configuration.
/// This operation also creates the key file in `ssh_key_dir` /// This operation also creates the key file in `ssh_key_dir`
/// and also commits changes to configuration, to prevent incoerent data /// and also commits changes to configuration, to prevent incoerent data
@@ -331,8 +283,6 @@ impl ConfigClient {
self.write_config() self.write_config()
} }
/// ### del_ssh_key
///
/// Delete a ssh key from configuration, using host as key. /// Delete a ssh key from configuration, using host as key.
/// This operation also unlinks the key file in `ssh_key_dir` /// This operation also unlinks the key file in `ssh_key_dir`
/// and also commits changes to configuration, to prevent incoerent data /// and also commits changes to configuration, to prevent incoerent data
@@ -363,8 +313,6 @@ impl ConfigClient {
self.write_config() self.write_config()
} }
/// ### get_ssh_key
///
/// Get ssh key from host. /// Get ssh key from host.
/// None is returned if key doesn't exist /// None is returned if key doesn't exist
/// `std::io::Error` is returned in case it was not possible to read the key file /// `std::io::Error` is returned in case it was not possible to read the key file
@@ -384,8 +332,6 @@ impl ConfigClient {
} }
} }
/// ### iter_ssh_keys
///
/// Get an iterator through hosts in the ssh key storage /// Get an iterator through hosts in the ssh key storage
pub fn iter_ssh_keys(&self) -> impl Iterator<Item = &String> + '_ { pub fn iter_ssh_keys(&self) -> impl Iterator<Item = &String> + '_ {
Box::new(self.config.remote.ssh_keys.keys()) Box::new(self.config.remote.ssh_keys.keys())
@@ -393,8 +339,6 @@ impl ConfigClient {
// I/O // I/O
/// ### write_config
///
/// Write configuration to file /// Write configuration to file
pub fn write_config(&self) -> Result<(), SerializerError> { pub fn write_config(&self) -> Result<(), SerializerError> {
if self.degraded { if self.degraded {
@@ -421,8 +365,6 @@ impl ConfigClient {
} }
} }
/// ### read_config
///
/// Read configuration from file (or reload it if already read) /// Read configuration from file (or reload it if already read)
pub fn read_config(&mut self) -> Result<(), SerializerError> { pub fn read_config(&mut self) -> Result<(), SerializerError> {
if self.degraded { if self.degraded {
@@ -456,16 +398,12 @@ impl ConfigClient {
} }
} }
/// ### make_ssh_host_key
///
/// Hosts are saved as `username@host` into configuration. /// Hosts are saved as `username@host` into configuration.
/// This method creates the key name, starting from host and username /// This method creates the key name, starting from host and username
fn make_ssh_host_key(host: &str, username: &str) -> String { fn make_ssh_host_key(host: &str, username: &str) -> String {
format!("{}@{}", username, host) format!("{}@{}", username, host)
} }
/// ### get_ssh_tokens
///
/// Get ssh tokens starting from ssh host key /// Get ssh tokens starting from ssh host key
/// Panics if key has invalid syntax /// Panics if key has invalid syntax
/// Returns: (host, username) /// Returns: (host, username)
@@ -475,8 +413,6 @@ impl ConfigClient {
(String::from(tokens[1]), String::from(tokens[0])) (String::from(tokens[1]), String::from(tokens[0]))
} }
/// ### make_io_err
///
/// Make serializer error from `std::io::Error` /// Make serializer error from `std::io::Error`
fn make_io_err(err: std::io::Error) -> Result<(), SerializerError> { fn make_io_err(err: std::io::Error) -> Result<(), SerializerError> {
Err(SerializerError::new_ex( Err(SerializerError::new_ex(
@@ -774,8 +710,6 @@ mod tests {
assert_eq!(err.to_string(), "IO error (permission denied)"); assert_eq!(err.to_string(), "IO error (permission denied)");
} }
/// ### get_paths
///
/// Get paths for configuration and keys directory /// Get paths for configuration and keys directory
fn get_paths(dir: &Path) -> (PathBuf, PathBuf) { fn get_paths(dir: &Path) -> (PathBuf, PathBuf) {
let mut k: PathBuf = PathBuf::from(dir); let mut k: PathBuf = PathBuf::from(dir);

View File

@@ -32,16 +32,12 @@ use std::fs::{OpenOptions, Permissions};
use std::io::{Read, Write}; use std::io::{Read, Write};
use std::path::{Path, PathBuf}; use std::path::{Path, PathBuf};
/// ## FileStorage
///
/// File storage is an implementation o the `KeyStorage` which uses a file to store the key /// File storage is an implementation o the `KeyStorage` which uses a file to store the key
pub struct FileStorage { pub struct FileStorage {
dir_path: PathBuf, dir_path: PathBuf,
} }
impl FileStorage { impl FileStorage {
/// ### new
///
/// Instantiates a new `FileStorage` /// Instantiates a new `FileStorage`
pub fn new(dir_path: &Path) -> Self { pub fn new(dir_path: &Path) -> Self {
FileStorage { FileStorage {
@@ -49,8 +45,6 @@ impl FileStorage {
} }
} }
/// ### make_file_path
///
/// Make file path for key file from `dir_path` and the application id /// Make file path for key file from `dir_path` and the application id
fn make_file_path(&self, storage_id: &str) -> PathBuf { fn make_file_path(&self, storage_id: &str) -> PathBuf {
let mut p: PathBuf = self.dir_path.clone(); let mut p: PathBuf = self.dir_path.clone();
@@ -61,8 +55,6 @@ impl FileStorage {
} }
impl KeyStorage for FileStorage { impl KeyStorage for FileStorage {
/// ### get_key
///
/// Retrieve key from the key storage. /// Retrieve key from the key storage.
/// The key might be acccess through an identifier, which identifies /// The key might be acccess through an identifier, which identifies
/// the key in the storage /// the key in the storage
@@ -85,8 +77,6 @@ impl KeyStorage for FileStorage {
} }
} }
/// ### set_key
///
/// Set the key into the key storage /// Set the key into the key storage
fn set_key(&self, storage_id: &str, key: &str) -> Result<(), KeyStorageError> { fn set_key(&self, storage_id: &str, key: &str) -> Result<(), KeyStorageError> {
let key_file: PathBuf = self.make_file_path(storage_id); let key_file: PathBuf = self.make_file_path(storage_id);

View File

@@ -30,16 +30,12 @@ use super::{KeyStorage, KeyStorageError};
// Ext // Ext
use keyring::{Keyring, KeyringError}; use keyring::{Keyring, KeyringError};
/// ## KeyringStorage
///
/// provides a `KeyStorage` implementation using the keyring crate /// provides a `KeyStorage` implementation using the keyring crate
pub struct KeyringStorage { pub struct KeyringStorage {
username: String, username: String,
} }
impl KeyringStorage { impl KeyringStorage {
/// ### new
///
/// Instantiates a new KeyringStorage /// Instantiates a new KeyringStorage
pub fn new(username: &str) -> Self { pub fn new(username: &str) -> Self {
KeyringStorage { KeyringStorage {
@@ -49,8 +45,6 @@ impl KeyringStorage {
} }
impl KeyStorage for KeyringStorage { impl KeyStorage for KeyringStorage {
/// ### get_key
///
/// Retrieve key from the key storage. /// Retrieve key from the key storage.
/// The key might be acccess through an identifier, which identifies /// The key might be acccess through an identifier, which identifies
/// the key in the storage /// the key in the storage
@@ -72,8 +66,6 @@ impl KeyStorage for KeyringStorage {
} }
} }
/// ### set_key
///
/// Set the key into the key storage /// Set the key into the key storage
fn set_key(&self, storage_id: &str, key: &str) -> Result<(), KeyStorageError> { fn set_key(&self, storage_id: &str, key: &str) -> Result<(), KeyStorageError> {
let storage: Keyring = Keyring::new(storage_id, self.username.as_str()); let storage: Keyring = Keyring::new(storage_id, self.username.as_str());

View File

@@ -32,8 +32,6 @@ pub mod keyringstorage;
// ext // ext
use thiserror::Error; use thiserror::Error;
/// ## KeyStorageError
///
/// defines the error type for the `KeyStorage` /// defines the error type for the `KeyStorage`
#[derive(Debug, Error, PartialEq)] #[derive(Debug, Error, PartialEq)]
pub enum KeyStorageError { pub enum KeyStorageError {
@@ -46,19 +44,13 @@ pub enum KeyStorageError {
NoSuchKey, NoSuchKey,
} }
/// ## KeyStorage
///
/// this traits provides the methods to communicate and interact with the key storage. /// this traits provides the methods to communicate and interact with the key storage.
pub trait KeyStorage { pub trait KeyStorage {
/// ### get_key
///
/// Retrieve key from the key storage. /// Retrieve key from the key storage.
/// The key might be acccess through an identifier, which identifies /// The key might be acccess through an identifier, which identifies
/// the key in the storage /// the key in the storage
fn get_key(&self, storage_id: &str) -> Result<String, KeyStorageError>; fn get_key(&self, storage_id: &str) -> Result<String, KeyStorageError>;
/// ### set_key
///
/// Set the key into the key storage /// Set the key into the key storage
fn set_key(&self, storage_id: &str, key: &str) -> Result<(), KeyStorageError>; fn set_key(&self, storage_id: &str, key: &str) -> Result<(), KeyStorageError>;

View File

@@ -6,14 +6,10 @@
use notify_rust::Hint; use notify_rust::Hint;
use notify_rust::{Notification as OsNotification, Timeout}; use notify_rust::{Notification as OsNotification, Timeout};
/// ## Notification
///
/// A notification helper which provides all the functions to send the available notifications for termscp /// A notification helper which provides all the functions to send the available notifications for termscp
pub struct Notification; pub struct Notification;
impl Notification { impl Notification {
/// ### transfer_completed
///
/// Notify a transfer has been completed with success /// Notify a transfer has been completed with success
pub fn transfer_completed<S: AsRef<str>>(body: S) { pub fn transfer_completed<S: AsRef<str>>(body: S) {
Self::notify( Self::notify(
@@ -23,15 +19,11 @@ impl Notification {
); );
} }
/// ### transfer_error
///
/// Notify a transfer has failed /// Notify a transfer has failed
pub fn transfer_error<S: AsRef<str>>(body: S) { pub fn transfer_error<S: AsRef<str>>(body: S) {
Self::notify("Transfer failed ❌", body.as_ref(), Some("transfer.error")); Self::notify("Transfer failed ❌", body.as_ref(), Some("transfer.error"));
} }
/// ### update_available
///
/// Notify a new version of termscp is available for download /// Notify a new version of termscp is available for download
pub fn update_available<S: AsRef<str>>(version: S) { pub fn update_available<S: AsRef<str>>(version: S) {
Self::notify( Self::notify(
@@ -41,8 +33,6 @@ impl Notification {
); );
} }
/// ### update_installed
///
/// Notify the update has been correctly installed /// Notify the update has been correctly installed
pub fn update_installed<S: AsRef<str>>(version: S) { pub fn update_installed<S: AsRef<str>>(version: S) {
Self::notify( Self::notify(
@@ -52,15 +42,11 @@ impl Notification {
); );
} }
/// ### update_failed
///
/// Notify the update installation has failed /// Notify the update installation has failed
pub fn update_failed<S: AsRef<str>>(err: S) { pub fn update_failed<S: AsRef<str>>(err: S) {
Self::notify("Update installation failed ❌", err.as_ref(), None); Self::notify("Update installation failed ❌", err.as_ref(), None);
} }
/// ### notify
///
/// Notify guest OS with provided Summary, body and optional category /// Notify guest OS with provided Summary, body and optional category
/// e.g. Category is supported on FreeBSD/Linux only /// e.g. Category is supported on FreeBSD/Linux only
#[allow(unused_variables)] #[allow(unused_variables)]

View File

@@ -37,8 +37,6 @@ pub struct SshKeyStorage {
} }
impl SshKeyStorage { impl SshKeyStorage {
/// ### storage_from_config
///
/// Create a `SshKeyStorage` starting from a `ConfigClient` /// Create a `SshKeyStorage` starting from a `ConfigClient`
pub fn storage_from_config(cfg_client: &ConfigClient) -> Self { pub fn storage_from_config(cfg_client: &ConfigClient) -> Self {
let mut hosts: HashMap<String, PathBuf> = let mut hosts: HashMap<String, PathBuf> =
@@ -65,8 +63,6 @@ impl SshKeyStorage {
SshKeyStorage { hosts } SshKeyStorage { hosts }
} }
/// ### empty
///
/// Create an empty ssh key storage; used in case `ConfigClient` is not available /// Create an empty ssh key storage; used in case `ConfigClient` is not available
#[cfg(test)] #[cfg(test)]
pub fn empty() -> Self { pub fn empty() -> Self {
@@ -75,16 +71,12 @@ impl SshKeyStorage {
} }
} }
/// ### make_mapkey
///
/// Make mapkey from host and username /// Make mapkey from host and username
fn make_mapkey(host: &str, username: &str) -> String { fn make_mapkey(host: &str, username: &str) -> String {
format!("{}@{}", username, host) format!("{}@{}", username, host)
} }
#[cfg(test)] #[cfg(test)]
/// ### add_key
///
/// Add a key to storage /// Add a key to storage
/// NOTE: available only for tests /// NOTE: available only for tests
pub fn add_key(&mut self, host: &str, username: &str, p: PathBuf) { pub fn add_key(&mut self, host: &str, username: &str, p: PathBuf) {
@@ -149,8 +141,6 @@ mod tests {
); );
} }
/// ### get_paths
///
/// Get paths for configuration and keys directory /// Get paths for configuration and keys directory
fn get_paths(dir: &Path) -> (PathBuf, PathBuf) { fn get_paths(dir: &Path) -> (PathBuf, PathBuf) {
let mut k: PathBuf = PathBuf::from(dir); let mut k: PathBuf = PathBuf::from(dir);

View File

@@ -35,8 +35,6 @@ use std::fs::OpenOptions;
use std::path::{Path, PathBuf}; use std::path::{Path, PathBuf};
use std::string::ToString; use std::string::ToString;
/// ## ThemeProvider
///
/// ThemeProvider provides a high level API to communicate with the termscp theme /// ThemeProvider provides a high level API to communicate with the termscp theme
pub struct ThemeProvider { pub struct ThemeProvider {
theme: Theme, // Theme loaded theme: Theme, // Theme loaded
@@ -45,8 +43,6 @@ pub struct ThemeProvider {
} }
impl ThemeProvider { impl ThemeProvider {
/// ### new
///
/// Instantiates a new `ThemeProvider` /// Instantiates a new `ThemeProvider`
pub fn new(theme_path: &Path) -> Result<Self, SerializerError> { pub fn new(theme_path: &Path) -> Result<Self, SerializerError> {
let default_theme: Theme = Theme::default(); let default_theme: Theme = Theme::default();
@@ -78,8 +74,6 @@ impl ThemeProvider {
Ok(provider) Ok(provider)
} }
/// ### degraded
///
/// Create a new theme provider which won't work with file system. /// Create a new theme provider which won't work with file system.
/// This is done in order to prevent a lot of `unwrap_or` on Ui /// This is done in order to prevent a lot of `unwrap_or` on Ui
pub fn degraded() -> Self { pub fn degraded() -> Self {
@@ -92,15 +86,11 @@ impl ThemeProvider {
// -- getters // -- getters
/// ### theme
///
/// Returns theme as reference /// Returns theme as reference
pub fn theme(&self) -> &Theme { pub fn theme(&self) -> &Theme {
&self.theme &self.theme
} }
/// ### theme_mut
///
/// Returns a mutable reference to the theme /// Returns a mutable reference to the theme
pub fn theme_mut(&mut self) -> &mut Theme { pub fn theme_mut(&mut self) -> &mut Theme {
&mut self.theme &mut self.theme
@@ -108,8 +98,6 @@ impl ThemeProvider {
// -- io // -- io
/// ### load
///
/// Load theme from file /// Load theme from file
pub fn load(&mut self) -> Result<(), SerializerError> { pub fn load(&mut self) -> Result<(), SerializerError> {
if self.degraded { if self.degraded {
@@ -146,8 +134,6 @@ impl ThemeProvider {
} }
} }
/// ### save
///
/// Save theme to file /// Save theme to file
pub fn save(&self) -> Result<(), SerializerError> { pub fn save(&self) -> Result<(), SerializerError> {
if self.degraded { if self.degraded {
@@ -235,8 +221,6 @@ mod test {
assert!(ThemeProvider::new(Path::new("/tmp/oifoif/omar")).is_err()); assert!(ThemeProvider::new(Path::new("/tmp/oifoif/omar")).is_err());
} }
/// ### get_theme_path
///
/// Get paths for theme file /// Get paths for theme file
fn get_theme_path(dir: &Path) -> PathBuf { fn get_theme_path(dir: &Path) -> PathBuf {
let mut p: PathBuf = PathBuf::from(dir); let mut p: PathBuf = PathBuf::from(dir);

View File

@@ -35,8 +35,6 @@ use crate::system::environment;
use std::path::PathBuf; use std::path::PathBuf;
impl AuthActivity { impl AuthActivity {
/// ### del_bookmark
///
/// Delete bookmark /// Delete bookmark
pub(super) fn del_bookmark(&mut self, idx: usize) { pub(super) fn del_bookmark(&mut self, idx: usize) {
if let Some(bookmarks_cli) = self.bookmarks_client.as_mut() { if let Some(bookmarks_cli) = self.bookmarks_client.as_mut() {
@@ -52,8 +50,6 @@ impl AuthActivity {
} }
} }
/// ### load_bookmark
///
/// Load selected bookmark (at index) to input fields /// Load selected bookmark (at index) to input fields
pub(super) fn load_bookmark(&mut self, idx: usize) { pub(super) fn load_bookmark(&mut self, idx: usize) {
if let Some(bookmarks_cli) = self.bookmarks_client.as_ref() { if let Some(bookmarks_cli) = self.bookmarks_client.as_ref() {
@@ -67,8 +63,6 @@ impl AuthActivity {
} }
} }
/// ### save_bookmark
///
/// Save current input fields as a bookmark /// Save current input fields as a bookmark
pub(super) fn save_bookmark(&mut self, name: String, save_password: bool) { pub(super) fn save_bookmark(&mut self, name: String, save_password: bool) {
let params = match self.collect_host_params() { let params = match self.collect_host_params() {
@@ -89,8 +83,6 @@ impl AuthActivity {
self.sort_bookmarks(); self.sort_bookmarks();
} }
} }
/// ### del_recent
///
/// Delete recent /// Delete recent
pub(super) fn del_recent(&mut self, idx: usize) { pub(super) fn del_recent(&mut self, idx: usize) {
if let Some(client) = self.bookmarks_client.as_mut() { if let Some(client) = self.bookmarks_client.as_mut() {
@@ -105,8 +97,6 @@ impl AuthActivity {
} }
} }
/// ### load_recent
///
/// Load selected recent (at index) to input fields /// Load selected recent (at index) to input fields
pub(super) fn load_recent(&mut self, idx: usize) { pub(super) fn load_recent(&mut self, idx: usize) {
if let Some(client) = self.bookmarks_client.as_ref() { if let Some(client) = self.bookmarks_client.as_ref() {
@@ -120,8 +110,6 @@ impl AuthActivity {
} }
} }
/// ### save_recent
///
/// Save current input fields as a "recent" /// Save current input fields as a "recent"
pub(super) fn save_recent(&mut self) { pub(super) fn save_recent(&mut self) {
let params = match self.collect_host_params() { let params = match self.collect_host_params() {
@@ -138,8 +126,6 @@ impl AuthActivity {
} }
} }
/// ### write_bookmarks
///
/// Write bookmarks to file /// Write bookmarks to file
fn write_bookmarks(&mut self) { fn write_bookmarks(&mut self) {
if let Some(bookmarks_cli) = self.bookmarks_client.as_ref() { if let Some(bookmarks_cli) = self.bookmarks_client.as_ref() {
@@ -149,8 +135,6 @@ impl AuthActivity {
} }
} }
/// ### init_bookmarks_client
///
/// Initialize bookmarks client /// Initialize bookmarks client
pub(super) fn init_bookmarks_client(&mut self) { pub(super) fn init_bookmarks_client(&mut self) {
// Get config dir // Get config dir
@@ -210,8 +194,6 @@ impl AuthActivity {
// -- privates // -- privates
/// ### sort_bookmarks
///
/// Sort bookmarks in list /// Sort bookmarks in list
fn sort_bookmarks(&mut self) { fn sort_bookmarks(&mut self) {
// Conver to lowercase when sorting // Conver to lowercase when sorting
@@ -219,16 +201,12 @@ impl AuthActivity {
.sort_by(|a, b| a.to_lowercase().as_str().cmp(b.to_lowercase().as_str())); .sort_by(|a, b| a.to_lowercase().as_str().cmp(b.to_lowercase().as_str()));
} }
/// ### sort_recents
///
/// Sort recents in list /// Sort recents in list
fn sort_recents(&mut self) { fn sort_recents(&mut self) {
// Reverse order // Reverse order
self.recents_list.sort_by(|a, b| b.cmp(a)); self.recents_list.sort_by(|a, b| b.cmp(a));
} }
/// ### load_bookmark_into_gui
///
/// Load bookmark data into the gui components /// Load bookmark data into the gui components
fn load_bookmark_into_gui(&mut self, bookmark: FileTransferParams) { fn load_bookmark_into_gui(&mut self, bookmark: FileTransferParams) {
// Load parameters into components // Load parameters into components

View File

@@ -57,8 +57,6 @@ impl ProtocolRadio {
} }
} }
/// ### protocol_opt_to_enum
///
/// Convert radio index for protocol into a `FileTransferProtocol` /// Convert radio index for protocol into a `FileTransferProtocol`
fn protocol_opt_to_enum(protocol: usize) -> FileTransferProtocol { fn protocol_opt_to_enum(protocol: usize) -> FileTransferProtocol {
match protocol { match protocol {
@@ -70,8 +68,6 @@ impl ProtocolRadio {
} }
} }
/// ### protocol_enum_to_opt
///
/// Convert `FileTransferProtocol` enum into radio group index /// Convert `FileTransferProtocol` enum into radio group index
fn protocol_enum_to_opt(protocol: FileTransferProtocol) -> usize { fn protocol_enum_to_opt(protocol: FileTransferProtocol) -> usize {
match protocol { match protocol {

View File

@@ -31,8 +31,6 @@ use crate::system::auto_update::{Release, Update, UpdateStatus};
use crate::system::notifications::Notification; use crate::system::notifications::Notification;
impl AuthActivity { impl AuthActivity {
/// ### get_default_port_for_protocol
///
/// Get the default port for protocol /// Get the default port for protocol
pub(super) fn get_default_port_for_protocol(protocol: FileTransferProtocol) -> u16 { pub(super) fn get_default_port_for_protocol(protocol: FileTransferProtocol) -> u16 {
match protocol { match protocol {
@@ -42,15 +40,11 @@ impl AuthActivity {
} }
} }
/// ### is_port_standard
///
/// Returns whether the port is standard or not /// Returns whether the port is standard or not
pub(super) fn is_port_standard(port: u16) -> bool { pub(super) fn is_port_standard(port: u16) -> bool {
port < 1024 port < 1024
} }
/// ### check_minimum_window_size
///
/// Check minimum window size window /// Check minimum window size window
pub(super) fn check_minimum_window_size(&mut self, height: u16) { pub(super) fn check_minimum_window_size(&mut self, height: u16) {
if height < 25 { if height < 25 {
@@ -61,8 +55,6 @@ impl AuthActivity {
} }
} }
/// ### collect_host_params
///
/// Collect host params as `FileTransferParams` /// Collect host params as `FileTransferParams`
pub(super) fn collect_host_params(&self) -> Result<FileTransferParams, &'static str> { pub(super) fn collect_host_params(&self) -> Result<FileTransferParams, &'static str> {
match self.protocol { match self.protocol {
@@ -71,8 +63,6 @@ impl AuthActivity {
} }
} }
/// ### collect_generic_host_params
///
/// Get input values from fields or return an error if fields are invalid to work as generic /// Get input values from fields or return an error if fields are invalid to work as generic
pub(super) fn collect_generic_host_params( pub(super) fn collect_generic_host_params(
&self, &self,
@@ -105,8 +95,6 @@ impl AuthActivity {
}) })
} }
/// ### collect_s3_host_params
///
/// Get input values from fields or return an error if fields are invalid to work as aws s3 /// Get input values from fields or return an error if fields are invalid to work as aws s3
pub(super) fn collect_s3_host_params(&self) -> Result<FileTransferParams, &'static str> { pub(super) fn collect_s3_host_params(&self) -> Result<FileTransferParams, &'static str> {
let (bucket, region, profile): (String, String, Option<String>) = let (bucket, region, profile): (String, String, Option<String>) =
@@ -126,8 +114,6 @@ impl AuthActivity {
// -- update install // -- update install
/// ### check_for_updates
///
/// If enabled in configuration, check for updates from Github /// If enabled in configuration, check for updates from Github
pub(super) fn check_for_updates(&mut self) { pub(super) fn check_for_updates(&mut self) {
debug!("Check for updates..."); debug!("Check for updates...");
@@ -171,8 +157,6 @@ impl AuthActivity {
} }
} }
/// ### install_update
///
/// Install latest termscp version via GUI /// Install latest termscp version via GUI
pub(super) fn install_update(&mut self) { pub(super) fn install_update(&mut self) {
// Umount release notes // Umount release notes

View File

@@ -127,8 +127,6 @@ pub enum Msg {
None, None,
} }
/// ## InputMask
///
/// Auth form input mask /// Auth form input mask
#[derive(Eq, PartialEq)] #[derive(Eq, PartialEq)]
enum InputMask { enum InputMask {
@@ -160,8 +158,6 @@ pub struct AuthActivity {
} }
impl AuthActivity { impl AuthActivity {
/// ### new
///
/// Instantiates a new AuthActivity /// Instantiates a new AuthActivity
pub fn new(ticks: Duration) -> AuthActivity { pub fn new(ticks: Duration) -> AuthActivity {
AuthActivity { AuthActivity {
@@ -180,36 +176,26 @@ impl AuthActivity {
} }
} }
/// ### context
///
/// Returns a reference to context /// Returns a reference to context
fn context(&self) -> &Context { fn context(&self) -> &Context {
self.context.as_ref().unwrap() self.context.as_ref().unwrap()
} }
/// ### context_mut
///
/// Returns a mutable reference to context /// Returns a mutable reference to context
fn context_mut(&mut self) -> &mut Context { fn context_mut(&mut self) -> &mut Context {
self.context.as_mut().unwrap() self.context.as_mut().unwrap()
} }
/// ### config
///
/// Returns config client reference /// Returns config client reference
fn config(&self) -> &ConfigClient { fn config(&self) -> &ConfigClient {
self.context().config() self.context().config()
} }
/// ### theme
///
/// Returns a reference to theme /// Returns a reference to theme
fn theme(&self) -> &Theme { fn theme(&self) -> &Theme {
self.context().theme_provider().theme() self.context().theme_provider().theme()
} }
/// ### input_mask
///
/// Get current input mask to show /// Get current input mask to show
fn input_mask(&self) -> InputMask { fn input_mask(&self) -> InputMask {
match self.protocol { match self.protocol {
@@ -222,8 +208,6 @@ impl AuthActivity {
} }
impl Activity for AuthActivity { impl Activity for AuthActivity {
/// ### on_create
///
/// `on_create` is the function which must be called to initialize the activity. /// `on_create` is the function which must be called to initialize the activity.
/// `on_create` must initialize all the data structures used by the activity /// `on_create` must initialize all the data structures used by the activity
/// Context is taken from activity manager and will be released only when activity is destroyed /// Context is taken from activity manager and will be released only when activity is destroyed
@@ -259,8 +243,6 @@ impl Activity for AuthActivity {
info!("Activity initialized"); info!("Activity initialized");
} }
/// ### on_draw
///
/// `on_draw` is the function which draws the graphical interface. /// `on_draw` is the function which draws the graphical interface.
/// This function must be called at each tick to refresh the interface /// This function must be called at each tick to refresh the interface
fn on_draw(&mut self) { fn on_draw(&mut self) {
@@ -288,8 +270,6 @@ impl Activity for AuthActivity {
} }
} }
/// ### will_umount
///
/// `will_umount` is the method which must be able to report to the activity manager, whether /// `will_umount` is the method which must be able to report to the activity manager, whether
/// the activity should be terminated or not. /// the activity should be terminated or not.
/// If not, the call will return `None`, otherwise return`Some(ExitReason)` /// If not, the call will return `None`, otherwise return`Some(ExitReason)`
@@ -297,8 +277,6 @@ impl Activity for AuthActivity {
self.exit_reason.as_ref() self.exit_reason.as_ref()
} }
/// ### on_destroy
///
/// `on_destroy` is the function which cleans up runtime variables and data before terminating the activity. /// `on_destroy` is the function which cleans up runtime variables and data before terminating the activity.
/// This function must be called once before terminating the activity. /// This function must be called once before terminating the activity.
/// This function finally releases the context /// This function finally releases the context

View File

@@ -37,8 +37,6 @@ use tuirealm::tui::widgets::Clear;
use tuirealm::{State, StateValue, Sub, SubClause, SubEventClause}; use tuirealm::{State, StateValue, Sub, SubClause, SubEventClause};
impl AuthActivity { impl AuthActivity {
/// ### init
///
/// Initialize view, mounting all startup components inside the view /// Initialize view, mounting all startup components inside the view
pub(super) fn init(&mut self) { pub(super) fn init(&mut self) {
let key_color = self.theme().misc_keys; let key_color = self.theme().misc_keys;
@@ -104,8 +102,6 @@ impl AuthActivity {
assert!(self.app.active(&Id::Protocol).is_ok()); assert!(self.app.active(&Id::Protocol).is_ok());
} }
/// ### view
///
/// Display view on canvas /// Display view on canvas
pub(super) fn view(&mut self) { pub(super) fn view(&mut self) {
self.redraw = false; self.redraw = false;
@@ -276,8 +272,6 @@ impl AuthActivity {
// -- partials // -- partials
/// ### view_bookmarks
///
/// Make text span from bookmarks /// Make text span from bookmarks
pub(super) fn view_bookmarks(&mut self) { pub(super) fn view_bookmarks(&mut self) {
let bookmarks: Vec<String> = self let bookmarks: Vec<String> = self
@@ -305,8 +299,6 @@ impl AuthActivity {
.is_ok()); .is_ok());
} }
/// ### view_recent_connections
///
/// View recent connections /// View recent connections
pub(super) fn view_recent_connections(&mut self) { pub(super) fn view_recent_connections(&mut self) {
let bookmarks: Vec<String> = self let bookmarks: Vec<String> = self
@@ -335,8 +327,6 @@ impl AuthActivity {
// -- mount // -- mount
/// ### mount_error
///
/// Mount error box /// Mount error box
pub(super) fn mount_error<S: AsRef<str>>(&mut self, text: S) { pub(super) fn mount_error<S: AsRef<str>>(&mut self, text: S) {
let err_color = self.theme().misc_error_dialog; let err_color = self.theme().misc_error_dialog;
@@ -351,15 +341,11 @@ impl AuthActivity {
assert!(self.app.active(&Id::ErrorPopup).is_ok()); assert!(self.app.active(&Id::ErrorPopup).is_ok());
} }
/// ### umount_error
///
/// Umount error message /// Umount error message
pub(super) fn umount_error(&mut self) { pub(super) fn umount_error(&mut self) {
let _ = self.app.umount(&Id::ErrorPopup); let _ = self.app.umount(&Id::ErrorPopup);
} }
/// ### mount_info
///
/// Mount info box /// Mount info box
pub(super) fn mount_info<S: AsRef<str>>(&mut self, text: S) { pub(super) fn mount_info<S: AsRef<str>>(&mut self, text: S) {
let color = self.theme().misc_info_dialog; let color = self.theme().misc_info_dialog;
@@ -374,15 +360,11 @@ impl AuthActivity {
assert!(self.app.active(&Id::InfoPopup).is_ok()); assert!(self.app.active(&Id::InfoPopup).is_ok());
} }
/// ### umount_info
///
/// Umount info message /// Umount info message
pub(super) fn umount_info(&mut self) { pub(super) fn umount_info(&mut self) {
let _ = self.app.umount(&Id::InfoPopup); let _ = self.app.umount(&Id::InfoPopup);
} }
/// ### mount_error
///
/// Mount wait box /// Mount wait box
pub(super) fn mount_wait(&mut self, text: &str) { pub(super) fn mount_wait(&mut self, text: &str) {
let wait_color = self.theme().misc_info_dialog; let wait_color = self.theme().misc_info_dialog;
@@ -397,15 +379,11 @@ impl AuthActivity {
assert!(self.app.active(&Id::WaitPopup).is_ok()); assert!(self.app.active(&Id::WaitPopup).is_ok());
} }
/// ### umount_wait
///
/// Umount wait message /// Umount wait message
pub(super) fn umount_wait(&mut self) { pub(super) fn umount_wait(&mut self) {
let _ = self.app.umount(&Id::WaitPopup); let _ = self.app.umount(&Id::WaitPopup);
} }
/// ### mount_size_err
///
/// Mount size error /// Mount size error
pub(super) fn mount_size_err(&mut self) { pub(super) fn mount_size_err(&mut self) {
// Mount // Mount
@@ -421,15 +399,11 @@ impl AuthActivity {
assert!(self.app.active(&Id::WindowSizeError).is_ok()); assert!(self.app.active(&Id::WindowSizeError).is_ok());
} }
/// ### umount_size_err
///
/// Umount error size error /// Umount error size error
pub(super) fn umount_size_err(&mut self) { pub(super) fn umount_size_err(&mut self) {
let _ = self.app.umount(&Id::WindowSizeError); let _ = self.app.umount(&Id::WindowSizeError);
} }
/// ### mount_quit
///
/// Mount quit popup /// Mount quit popup
pub(super) fn mount_quit(&mut self) { pub(super) fn mount_quit(&mut self) {
// Protocol // Protocol
@@ -445,15 +419,11 @@ impl AuthActivity {
assert!(self.app.active(&Id::QuitPopup).is_ok()); assert!(self.app.active(&Id::QuitPopup).is_ok());
} }
/// ### umount_quit
///
/// Umount quit popup /// Umount quit popup
pub(super) fn umount_quit(&mut self) { pub(super) fn umount_quit(&mut self) {
let _ = self.app.umount(&Id::QuitPopup); let _ = self.app.umount(&Id::QuitPopup);
} }
/// ### mount_bookmark_del_dialog
///
/// Mount bookmark delete dialog /// Mount bookmark delete dialog
pub(super) fn mount_bookmark_del_dialog(&mut self) { pub(super) fn mount_bookmark_del_dialog(&mut self) {
let warn_color = self.theme().misc_warn_dialog; let warn_color = self.theme().misc_warn_dialog;
@@ -468,15 +438,11 @@ impl AuthActivity {
assert!(self.app.active(&Id::DeleteBookmarkPopup).is_ok()); assert!(self.app.active(&Id::DeleteBookmarkPopup).is_ok());
} }
/// ### umount_bookmark_del_dialog
///
/// umount delete bookmark dialog /// umount delete bookmark dialog
pub(super) fn umount_bookmark_del_dialog(&mut self) { pub(super) fn umount_bookmark_del_dialog(&mut self) {
let _ = self.app.umount(&Id::DeleteBookmarkPopup); let _ = self.app.umount(&Id::DeleteBookmarkPopup);
} }
/// ### mount_bookmark_del_dialog
///
/// Mount recent delete dialog /// Mount recent delete dialog
pub(super) fn mount_recent_del_dialog(&mut self) { pub(super) fn mount_recent_del_dialog(&mut self) {
let warn_color = self.theme().misc_warn_dialog; let warn_color = self.theme().misc_warn_dialog;
@@ -491,15 +457,11 @@ impl AuthActivity {
assert!(self.app.active(&Id::DeleteRecentPopup).is_ok()); assert!(self.app.active(&Id::DeleteRecentPopup).is_ok());
} }
/// ### umount_recent_del_dialog
///
/// umount delete recent dialog /// umount delete recent dialog
pub(super) fn umount_recent_del_dialog(&mut self) { pub(super) fn umount_recent_del_dialog(&mut self) {
let _ = self.app.umount(&Id::DeleteRecentPopup); let _ = self.app.umount(&Id::DeleteRecentPopup);
} }
/// ### mount_bookmark_save_dialog
///
/// Mount bookmark save dialog /// Mount bookmark save dialog
pub(super) fn mount_bookmark_save_dialog(&mut self) { pub(super) fn mount_bookmark_save_dialog(&mut self) {
let save_color = self.theme().misc_save_dialog; let save_color = self.theme().misc_save_dialog;
@@ -524,16 +486,12 @@ impl AuthActivity {
assert!(self.app.active(&Id::BookmarkName).is_ok()); assert!(self.app.active(&Id::BookmarkName).is_ok());
} }
/// ### umount_bookmark_save_dialog
///
/// Umount bookmark save dialog /// Umount bookmark save dialog
pub(super) fn umount_bookmark_save_dialog(&mut self) { pub(super) fn umount_bookmark_save_dialog(&mut self) {
let _ = self.app.umount(&Id::BookmarkName); let _ = self.app.umount(&Id::BookmarkName);
let _ = self.app.umount(&Id::BookmarkSavePassword); let _ = self.app.umount(&Id::BookmarkSavePassword);
} }
/// ### mount_keybindings
///
/// Mount keybindings /// Mount keybindings
pub(super) fn mount_keybindings(&mut self) { pub(super) fn mount_keybindings(&mut self) {
let key_color = self.theme().misc_keys; let key_color = self.theme().misc_keys;
@@ -549,15 +507,11 @@ impl AuthActivity {
assert!(self.app.active(&Id::Keybindings).is_ok()); assert!(self.app.active(&Id::Keybindings).is_ok());
} }
/// ### umount_help
///
/// Umount help /// Umount help
pub(super) fn umount_help(&mut self) { pub(super) fn umount_help(&mut self) {
let _ = self.app.umount(&Id::Keybindings); let _ = self.app.umount(&Id::Keybindings);
} }
/// ### mount_release_notes
///
/// mount release notes text area /// mount release notes text area
pub(super) fn mount_release_notes(&mut self) { pub(super) fn mount_release_notes(&mut self) {
if let Some(ctx) = self.context.as_ref() { if let Some(ctx) = self.context.as_ref() {
@@ -585,8 +539,6 @@ impl AuthActivity {
} }
} }
/// ### umount_release_notes
///
/// Umount release notes text area /// Umount release notes text area
pub(super) fn umount_release_notes(&mut self) { pub(super) fn umount_release_notes(&mut self) {
let _ = self.app.umount(&Id::NewVersionChangelog); let _ = self.app.umount(&Id::NewVersionChangelog);
@@ -691,8 +643,6 @@ impl AuthActivity {
// -- query // -- query
/// ### get_generic_params
///
/// Collect input values from view /// Collect input values from view
pub(super) fn get_generic_params_input(&self) -> (String, u16, String, String) { pub(super) fn get_generic_params_input(&self) -> (String, u16, String, String) {
let addr: String = self.get_input_addr(); let addr: String = self.get_input_addr();
@@ -702,8 +652,6 @@ impl AuthActivity {
(addr, port, username, password) (addr, port, username, password)
} }
/// ### get_s3_params_input
///
/// Collect s3 input values from view /// Collect s3 input values from view
pub(super) fn get_s3_params_input(&self) -> (String, String, Option<String>) { pub(super) fn get_s3_params_input(&self) -> (String, String, Option<String>) {
let bucket: String = self.get_input_s3_bucket(); let bucket: String = self.get_input_s3_bucket();
@@ -764,8 +712,6 @@ impl AuthActivity {
} }
} }
/// ### get_new_bookmark
///
/// Get new bookmark params /// Get new bookmark params
pub(super) fn get_new_bookmark(&self) -> (String, bool) { pub(super) fn get_new_bookmark(&self) -> (String, bool) {
let name = match self.app.state(&Id::BookmarkName) { let name = match self.app.state(&Id::BookmarkName) {
@@ -784,8 +730,6 @@ impl AuthActivity {
// -- len // -- len
/// ### input_mask_size
///
/// Returns the input mask size based on current input mask /// Returns the input mask size based on current input mask
pub(super) fn input_mask_size(&self) -> u16 { pub(super) fn input_mask_size(&self) -> u16 {
match self.input_mask() { match self.input_mask() {
@@ -796,16 +740,12 @@ impl AuthActivity {
// -- fmt // -- fmt
/// ### fmt_bookmark
///
/// Format bookmark to display on ui /// Format bookmark to display on ui
fn fmt_bookmark(name: &str, b: FileTransferParams) -> String { fn fmt_bookmark(name: &str, b: FileTransferParams) -> String {
let addr: String = Self::fmt_recent(b); let addr: String = Self::fmt_recent(b);
format!("{} ({})", name, addr) format!("{} ({})", name, addr)
} }
/// ### fmt_recent
///
/// Format recent connection to display on ui /// Format recent connection to display on ui
fn fmt_recent(b: FileTransferParams) -> String { fn fmt_recent(b: FileTransferParams) -> String {
let protocol: String = b.protocol.to_string().to_lowercase(); let protocol: String = b.protocol.to_string().to_lowercase();
@@ -881,8 +821,6 @@ impl AuthActivity {
.is_ok()); .is_ok());
} }
/// ### no_popup_mounted_clause
///
/// Returns a sub clause which requires that no popup is mounted in order to be satisfied /// Returns a sub clause which requires that no popup is mounted in order to be satisfied
fn no_popup_mounted_clause() -> SubClause<Id> { fn no_popup_mounted_clause() -> SubClause<Id> {
SubClause::And( SubClause::And(

View File

@@ -32,8 +32,6 @@ use remotefs::Directory;
use std::path::PathBuf; use std::path::PathBuf;
impl FileTransferActivity { impl FileTransferActivity {
/// ### action_enter_local_dir
///
/// Enter a directory on local host from entry /// Enter a directory on local host from entry
/// Return true whether the directory changed /// Return true whether the directory changed
pub(crate) fn action_enter_local_dir(&mut self, dir: Directory, block_sync: bool) -> bool { pub(crate) fn action_enter_local_dir(&mut self, dir: Directory, block_sync: bool) -> bool {
@@ -44,8 +42,6 @@ impl FileTransferActivity {
true true
} }
/// ### action_enter_remote_dir
///
/// Enter a directory on local host from entry /// Enter a directory on local host from entry
/// Return true whether the directory changed /// Return true whether the directory changed
pub(crate) fn action_enter_remote_dir(&mut self, dir: Directory, block_sync: bool) -> bool { pub(crate) fn action_enter_remote_dir(&mut self, dir: Directory, block_sync: bool) -> bool {
@@ -56,8 +52,6 @@ impl FileTransferActivity {
true true
} }
/// ### action_change_local_dir
///
/// Change local directory reading value from input /// Change local directory reading value from input
pub(crate) fn action_change_local_dir(&mut self, input: String, block_sync: bool) { pub(crate) fn action_change_local_dir(&mut self, input: String, block_sync: bool) {
let dir_path: PathBuf = self.local_to_abs_path(PathBuf::from(input.as_str()).as_path()); let dir_path: PathBuf = self.local_to_abs_path(PathBuf::from(input.as_str()).as_path());
@@ -68,8 +62,6 @@ impl FileTransferActivity {
} }
} }
/// ### action_change_remote_dir
///
/// Change remote directory reading value from input /// Change remote directory reading value from input
pub(crate) fn action_change_remote_dir(&mut self, input: String, block_sync: bool) { pub(crate) fn action_change_remote_dir(&mut self, input: String, block_sync: bool) {
let dir_path: PathBuf = self.remote_to_abs_path(PathBuf::from(input.as_str()).as_path()); let dir_path: PathBuf = self.remote_to_abs_path(PathBuf::from(input.as_str()).as_path());
@@ -80,8 +72,6 @@ impl FileTransferActivity {
} }
} }
/// ### action_go_to_previous_local_dir
///
/// Go to previous directory from localhost /// Go to previous directory from localhost
pub(crate) fn action_go_to_previous_local_dir(&mut self, block_sync: bool) { pub(crate) fn action_go_to_previous_local_dir(&mut self, block_sync: bool) {
if let Some(d) = self.local_mut().popd() { if let Some(d) = self.local_mut().popd() {
@@ -93,8 +83,6 @@ impl FileTransferActivity {
} }
} }
/// ### action_go_to_previous_remote_dir
///
/// Go to previous directory from remote host /// Go to previous directory from remote host
pub(crate) fn action_go_to_previous_remote_dir(&mut self, block_sync: bool) { pub(crate) fn action_go_to_previous_remote_dir(&mut self, block_sync: bool) {
if let Some(d) = self.remote_mut().popd() { if let Some(d) = self.remote_mut().popd() {
@@ -106,8 +94,6 @@ impl FileTransferActivity {
} }
} }
/// ### action_go_to_local_upper_dir
///
/// Go to upper directory on local host /// Go to upper directory on local host
pub(crate) fn action_go_to_local_upper_dir(&mut self, block_sync: bool) { pub(crate) fn action_go_to_local_upper_dir(&mut self, block_sync: bool) {
// Get pwd // Get pwd

View File

@@ -32,8 +32,6 @@ use remotefs::{Entry, RemoteErrorType};
use std::path::{Path, PathBuf}; use std::path::{Path, PathBuf};
impl FileTransferActivity { impl FileTransferActivity {
/// ### action_local_copy
///
/// Copy file on local /// Copy file on local
pub(crate) fn action_local_copy(&mut self, input: String) { pub(crate) fn action_local_copy(&mut self, input: String) {
match self.get_local_selected_entries() { match self.get_local_selected_entries() {
@@ -59,8 +57,6 @@ impl FileTransferActivity {
} }
} }
/// ### action_remote_copy
///
/// Copy file on remote /// Copy file on remote
pub(crate) fn action_remote_copy(&mut self, input: String) { pub(crate) fn action_remote_copy(&mut self, input: String) {
match self.get_remote_selected_entries() { match self.get_remote_selected_entries() {
@@ -140,8 +136,6 @@ impl FileTransferActivity {
} }
} }
/// ### tricky_copy
///
/// Tricky copy will be used whenever copy command is not available on remote host /// Tricky copy will be used whenever copy command is not available on remote host
pub(super) fn tricky_copy(&mut self, entry: Entry, dest: &Path) -> Result<(), String> { pub(super) fn tricky_copy(&mut self, entry: Entry, dest: &Path) -> Result<(), String> {
// NOTE: VERY IMPORTANT; wait block must be umounted or something really bad will happen // NOTE: VERY IMPORTANT; wait block must be umounted or something really bad will happen

View File

@@ -84,8 +84,6 @@ impl FileTransferActivity {
self.reload_remote_dir(); self.reload_remote_dir();
} }
/// ### edit_local_file
///
/// Edit a file on localhost /// Edit a file on localhost
fn edit_local_file(&mut self, path: &Path) -> Result<(), String> { fn edit_local_file(&mut self, path: &Path) -> Result<(), String> {
// Read first 2048 bytes or less from file to check if it is textual // Read first 2048 bytes or less from file to check if it is textual
@@ -147,8 +145,6 @@ impl FileTransferActivity {
Ok(()) Ok(())
} }
/// ### edit_remote_file
///
/// Edit file on remote host /// Edit file on remote host
fn edit_remote_file(&mut self, file: File) -> Result<(), String> { fn edit_remote_file(&mut self, file: File) -> Result<(), String> {
// Create temp file // Create temp file

View File

@@ -75,8 +75,6 @@ impl From<Vec<&Entry>> for SelectedEntry {
} }
impl FileTransferActivity { impl FileTransferActivity {
/// ### get_local_selected_entries
///
/// Get local file entry /// Get local file entry
pub(crate) fn get_local_selected_entries(&self) -> SelectedEntry { pub(crate) fn get_local_selected_entries(&self) -> SelectedEntry {
match self.get_selected_index(&Id::ExplorerLocal) { match self.get_selected_index(&Id::ExplorerLocal) {
@@ -93,8 +91,6 @@ impl FileTransferActivity {
} }
} }
/// ### get_remote_selected_entries
///
/// Get remote file entry /// Get remote file entry
pub(crate) fn get_remote_selected_entries(&self) -> SelectedEntry { pub(crate) fn get_remote_selected_entries(&self) -> SelectedEntry {
match self.get_selected_index(&Id::ExplorerRemote) { match self.get_selected_index(&Id::ExplorerRemote) {
@@ -111,8 +107,6 @@ impl FileTransferActivity {
} }
} }
/// ### get_remote_selected_entries
///
/// Get remote file entry /// Get remote file entry
pub(crate) fn get_found_selected_entries(&self) -> SelectedEntry { pub(crate) fn get_found_selected_entries(&self) -> SelectedEntry {
match self.get_selected_index(&Id::ExplorerFind) { match self.get_selected_index(&Id::ExplorerFind) {

View File

@@ -31,8 +31,6 @@ use super::{Entry, FileTransferActivity, LogLevel, SelectedEntry, TransferPayloa
use std::path::{Path, PathBuf}; use std::path::{Path, PathBuf};
impl FileTransferActivity { impl FileTransferActivity {
/// ### action_open_local
///
/// Open local file /// Open local file
pub(crate) fn action_open_local(&mut self) { pub(crate) fn action_open_local(&mut self) {
let entries: Vec<Entry> = match self.get_local_selected_entries() { let entries: Vec<Entry> = match self.get_local_selected_entries() {
@@ -45,8 +43,6 @@ impl FileTransferActivity {
.for_each(|x| self.action_open_local_file(x, None)); .for_each(|x| self.action_open_local_file(x, None));
} }
/// ### action_open_remote
///
/// Open local file /// Open local file
pub(crate) fn action_open_remote(&mut self) { pub(crate) fn action_open_remote(&mut self) {
let entries: Vec<Entry> = match self.get_remote_selected_entries() { let entries: Vec<Entry> = match self.get_remote_selected_entries() {
@@ -59,15 +55,11 @@ impl FileTransferActivity {
.for_each(|x| self.action_open_remote_file(x, None)); .for_each(|x| self.action_open_remote_file(x, None));
} }
/// ### action_open_local_file
///
/// Perform open lopcal file /// Perform open lopcal file
pub(crate) fn action_open_local_file(&mut self, entry: &Entry, open_with: Option<&str>) { pub(crate) fn action_open_local_file(&mut self, entry: &Entry, open_with: Option<&str>) {
self.open_path_with(entry.path(), open_with); self.open_path_with(entry.path(), open_with);
} }
/// ### action_open_local
///
/// Open remote file. The file is first downloaded to a temporary directory on localhost /// Open remote file. The file is first downloaded to a temporary directory on localhost
pub(crate) fn action_open_remote_file(&mut self, entry: &Entry, open_with: Option<&str>) { pub(crate) fn action_open_remote_file(&mut self, entry: &Entry, open_with: Option<&str>) {
// Download file // Download file
@@ -107,8 +99,6 @@ impl FileTransferActivity {
} }
} }
/// ### action_local_open_with
///
/// Open selected file with provided application /// Open selected file with provided application
pub(crate) fn action_local_open_with(&mut self, with: &str) { pub(crate) fn action_local_open_with(&mut self, with: &str) {
let entries: Vec<Entry> = match self.get_local_selected_entries() { let entries: Vec<Entry> = match self.get_local_selected_entries() {
@@ -122,8 +112,6 @@ impl FileTransferActivity {
.for_each(|x| self.action_open_local_file(x, Some(with))); .for_each(|x| self.action_open_local_file(x, Some(with)));
} }
/// ### action_remote_open_with
///
/// Open selected file with provided application /// Open selected file with provided application
pub(crate) fn action_remote_open_with(&mut self, with: &str) { pub(crate) fn action_remote_open_with(&mut self, with: &str) {
let entries: Vec<Entry> = match self.get_remote_selected_entries() { let entries: Vec<Entry> = match self.get_remote_selected_entries() {
@@ -137,8 +125,6 @@ impl FileTransferActivity {
.for_each(|x| self.action_open_remote_file(x, Some(with))); .for_each(|x| self.action_open_remote_file(x, Some(with)));
} }
/// ### open_path_with
///
/// Common function which opens a path with default or specified program. /// Common function which opens a path with default or specified program.
fn open_path_with(&mut self, p: &Path, with: Option<&str>) { fn open_path_with(&mut self, p: &Path, with: Option<&str>) {
// Open file // Open file

View File

@@ -131,8 +131,6 @@ impl FileTransferActivity {
} }
} }
/// ### tricky_move
///
/// Tricky move will be used whenever copy command is not available on remote host. /// Tricky move will be used whenever copy command is not available on remote host.
/// It basically uses the tricky_copy function, then it just deletes the previous entry (`entry`) /// It basically uses the tricky_copy function, then it just deletes the previous entry (`entry`)
fn tricky_move(&mut self, entry: &Entry, dest: &Path) { fn tricky_move(&mut self, entry: &Entry, dest: &Path) {

View File

@@ -49,8 +49,6 @@ impl FileTransferActivity {
self.remote_recv_file(TransferOpts::default()); self.remote_recv_file(TransferOpts::default());
} }
/// ### action_finalize_pending_transfer
///
/// Finalize "pending" transfer. /// Finalize "pending" transfer.
/// The pending transfer is created after a transfer which required a user action to be completed first. /// The pending transfer is created after a transfer which required a user action to be completed first.
/// The name of the file to transfer, is contained in the storage at `STORAGE_PENDING_TRANSFER`. /// The name of the file to transfer, is contained in the storage at `STORAGE_PENDING_TRANSFER`.
@@ -228,8 +226,6 @@ impl FileTransferActivity {
} }
} }
/// ### set_pending_transfer
///
/// Set pending transfer into storage /// Set pending transfer into storage
pub(crate) fn set_pending_transfer(&mut self, file_name: &str) { pub(crate) fn set_pending_transfer(&mut self, file_name: &str) {
self.mount_radio_replace(file_name); self.mount_radio_replace(file_name);
@@ -239,8 +235,6 @@ impl FileTransferActivity {
.set_string(STORAGE_PENDING_TRANSFER, file_name.to_string()); .set_string(STORAGE_PENDING_TRANSFER, file_name.to_string());
} }
/// ### set_pending_transfer_many
///
/// Set pending transfer for many files into storage and mount radio /// Set pending transfer for many files into storage and mount radio
pub(crate) fn set_pending_transfer_many(&mut self, files: Vec<&Entry>, dest_path: &str) { pub(crate) fn set_pending_transfer_many(&mut self, files: Vec<&Entry>, dest_path: &str) {
let file_names: Vec<&str> = files.iter().map(|x| x.name()).collect(); let file_names: Vec<&str> = files.iter().map(|x| x.name()).collect();
@@ -250,8 +244,6 @@ impl FileTransferActivity {
.set_string(STORAGE_PENDING_TRANSFER, dest_path.to_string()); .set_string(STORAGE_PENDING_TRANSFER, dest_path.to_string());
} }
/// ### file_to_check
///
/// Get file to check for path /// Get file to check for path
pub(crate) fn file_to_check(e: &Entry, alt: Option<&String>) -> PathBuf { pub(crate) fn file_to_check(e: &Entry, alt: Option<&String>) -> PathBuf {
match alt { match alt {

View File

@@ -36,8 +36,6 @@ enum SubmitAction {
} }
impl FileTransferActivity { impl FileTransferActivity {
/// ### action_submit_local
///
/// Decides which action to perform on submit for local explorer /// Decides which action to perform on submit for local explorer
/// Return true whether the directory changed /// Return true whether the directory changed
pub(crate) fn action_submit_local(&mut self, entry: Entry) -> bool { pub(crate) fn action_submit_local(&mut self, entry: Entry) -> bool {
@@ -78,8 +76,6 @@ impl FileTransferActivity {
} }
} }
/// ### action_submit_remote
///
/// Decides which action to perform on submit for remote explorer /// Decides which action to perform on submit for remote explorer
/// Return true whether the directory changed /// Return true whether the directory changed
pub(crate) fn action_submit_remote(&mut self, entry: Entry) -> bool { pub(crate) fn action_submit_remote(&mut self, entry: Entry) -> bool {

View File

@@ -222,8 +222,6 @@ impl Component<Msg, NoUserEvent> for Log {
// -- states // -- states
/// ## OwnStates
///
/// OwnStates contains states for this component /// OwnStates contains states for this component
#[derive(Clone, Default)] #[derive(Clone, Default)]
struct OwnStates { struct OwnStates {
@@ -232,22 +230,16 @@ struct OwnStates {
} }
impl OwnStates { impl OwnStates {
/// ### set_list_len
///
/// Set list length /// Set list length
pub fn set_list_len(&mut self, len: usize) { pub fn set_list_len(&mut self, len: usize) {
self.list_len = len; self.list_len = len;
} }
/// ### get_list_index
///
/// Return current value for list index /// Return current value for list index
pub fn get_list_index(&self) -> usize { pub fn get_list_index(&self) -> usize {
self.list_index self.list_index
} }
/// ### incr_list_index
///
/// Incremenet list index /// Incremenet list index
pub fn incr_list_index(&mut self) { pub fn incr_list_index(&mut self) {
// Check if index is at last element // Check if index is at last element
@@ -256,8 +248,6 @@ impl OwnStates {
} }
} }
/// ### decr_list_index
///
/// Decrement list index /// Decrement list index
pub fn decr_list_index(&mut self) { pub fn decr_list_index(&mut self) {
// Check if index is bigger than 0 // Check if index is bigger than 0
@@ -266,8 +256,6 @@ impl OwnStates {
} }
} }
/// ### list_index_at_last
///
/// Set list index at last item /// Set list index at last item
pub fn list_index_at_last(&mut self) { pub fn list_index_at_last(&mut self) {
self.list_index = match self.list_len { self.list_index = match self.list_len {
@@ -276,8 +264,6 @@ impl OwnStates {
}; };
} }
/// ### reset_list_index
///
/// Reset list index to last element /// Reset list index to last element
pub fn reset_list_index(&mut self) { pub fn reset_list_index(&mut self) {
self.list_index = 0; // Last element is always 0 self.list_index = 0; // Last element is always 0

View File

@@ -36,8 +36,6 @@ use tuirealm::{MockComponent, Props, State, StateValue};
pub const FILE_LIST_CMD_SELECT_ALL: &str = "A"; pub const FILE_LIST_CMD_SELECT_ALL: &str = "A";
/// ## OwnStates
///
/// OwnStates contains states for this component /// OwnStates contains states for this component
#[derive(Clone, Default)] #[derive(Clone, Default)]
struct OwnStates { struct OwnStates {
@@ -46,23 +44,17 @@ struct OwnStates {
} }
impl OwnStates { impl OwnStates {
/// ### init_list_states
///
/// Initialize list states /// Initialize list states
pub fn init_list_states(&mut self, len: usize) { pub fn init_list_states(&mut self, len: usize) {
self.selected = Vec::with_capacity(len); self.selected = Vec::with_capacity(len);
self.fix_list_index(); self.fix_list_index();
} }
/// ### list_index
///
/// Return current value for list index /// Return current value for list index
pub fn list_index(&self) -> usize { pub fn list_index(&self) -> usize {
self.list_index self.list_index
} }
/// ### incr_list_index
///
/// Incremenet list index. /// Incremenet list index.
/// If `can_rewind` is `true` the index rewinds when boundary is reached /// If `can_rewind` is `true` the index rewinds when boundary is reached
pub fn incr_list_index(&mut self, can_rewind: bool) { pub fn incr_list_index(&mut self, can_rewind: bool) {
@@ -74,8 +66,6 @@ impl OwnStates {
} }
} }
/// ### decr_list_index
///
/// Decrement list index /// Decrement list index
/// If `can_rewind` is `true` the index rewinds when boundary is reached /// If `can_rewind` is `true` the index rewinds when boundary is reached
pub fn decr_list_index(&mut self, can_rewind: bool) { pub fn decr_list_index(&mut self, can_rewind: bool) {
@@ -98,36 +88,26 @@ impl OwnStates {
}; };
} }
/// ### list_len
///
/// Returns the length of the file list, which is actually the capacity of the selection vector /// Returns the length of the file list, which is actually the capacity of the selection vector
pub fn list_len(&self) -> usize { pub fn list_len(&self) -> usize {
self.selected.capacity() self.selected.capacity()
} }
/// ### is_selected
///
/// Returns whether the file with index `entry` is selected /// Returns whether the file with index `entry` is selected
pub fn is_selected(&self, entry: usize) -> bool { pub fn is_selected(&self, entry: usize) -> bool {
self.selected.contains(&entry) self.selected.contains(&entry)
} }
/// ### is_selection_empty
///
/// Returns whether the selection is currently empty /// Returns whether the selection is currently empty
pub fn is_selection_empty(&self) -> bool { pub fn is_selection_empty(&self) -> bool {
self.selected.is_empty() self.selected.is_empty()
} }
/// ### get_selection
///
/// Returns current file selection /// Returns current file selection
pub fn get_selection(&self) -> Vec<usize> { pub fn get_selection(&self) -> Vec<usize> {
self.selected.clone() self.selected.clone()
} }
/// ### fix_list_index
///
/// Keep index if possible, otherwise set to lenght - 1 /// Keep index if possible, otherwise set to lenght - 1
fn fix_list_index(&mut self) { fn fix_list_index(&mut self) {
if self.list_index >= self.list_len() && self.list_len() > 0 { if self.list_index >= self.list_len() && self.list_len() > 0 {
@@ -139,8 +119,6 @@ impl OwnStates {
// -- select manipulation // -- select manipulation
/// ### toggle_file
///
/// Select or deselect file with provided entry index /// Select or deselect file with provided entry index
pub fn toggle_file(&mut self, entry: usize) { pub fn toggle_file(&mut self, entry: usize) {
match self.is_selected(entry) { match self.is_selected(entry) {
@@ -149,8 +127,6 @@ impl OwnStates {
} }
} }
/// ### select_all
///
/// Select all files /// Select all files
pub fn select_all(&mut self) { pub fn select_all(&mut self) {
for i in 0..self.list_len() { for i in 0..self.list_len() {
@@ -158,8 +134,6 @@ impl OwnStates {
} }
} }
/// ### select
///
/// Select provided index if not selected yet /// Select provided index if not selected yet
fn select(&mut self, entry: usize) { fn select(&mut self, entry: usize) {
if !self.is_selected(entry) { if !self.is_selected(entry) {
@@ -167,8 +141,6 @@ impl OwnStates {
} }
} }
/// ### deselect
///
/// Remove element file with associated index /// Remove element file with associated index
fn deselect(&mut self, entry: usize) { fn deselect(&mut self, entry: usize) {
if self.is_selected(entry) { if self.is_selected(entry) {

View File

@@ -31,8 +31,6 @@ use crate::system::config_client::ConfigClient;
use remotefs::Entry; use remotefs::Entry;
use std::path::Path; use std::path::Path;
/// ## FileExplorerTab
///
/// File explorer tab /// File explorer tab
#[derive(Clone, Copy, PartialEq, Eq)] #[derive(Clone, Copy, PartialEq, Eq)]
pub enum FileExplorerTab { pub enum FileExplorerTab {
@@ -42,8 +40,6 @@ pub enum FileExplorerTab {
FindRemote, // Find result tab FindRemote, // Find result tab
} }
/// ## FoundExplorerTab
///
/// Describes the explorer tab type /// Describes the explorer tab type
#[derive(Copy, Clone, Debug)] #[derive(Copy, Clone, Debug)]
pub enum FoundExplorerTab { pub enum FoundExplorerTab {
@@ -51,8 +47,6 @@ pub enum FoundExplorerTab {
Remote, Remote,
} }
/// ## Browser
///
/// Browser contains the browser options /// Browser contains the browser options
pub struct Browser { pub struct Browser {
local: FileExplorer, // Local File explorer state local: FileExplorer, // Local File explorer state
@@ -63,8 +57,6 @@ pub struct Browser {
} }
impl Browser { impl Browser {
/// ### new
///
/// Build a new `Browser` struct /// Build a new `Browser` struct
pub fn new(cli: &ConfigClient) -> Self { pub fn new(cli: &ConfigClient) -> Self {
Self { Self {
@@ -110,8 +102,6 @@ impl Browser {
self.found = None; self.found = None;
} }
/// ### found_tab
///
/// Returns found tab if any /// Returns found tab if any
pub fn found_tab(&self) -> Option<FoundExplorerTab> { pub fn found_tab(&self) -> Option<FoundExplorerTab> {
self.found.as_ref().map(|x| x.0) self.found.as_ref().map(|x| x.0)
@@ -121,22 +111,16 @@ impl Browser {
self.tab self.tab
} }
/// ### change_tab
///
/// Update tab value /// Update tab value
pub fn change_tab(&mut self, tab: FileExplorerTab) { pub fn change_tab(&mut self, tab: FileExplorerTab) {
self.tab = tab; self.tab = tab;
} }
/// ### toggle_sync_browsing
///
/// Invert the current state for the sync browsing /// Invert the current state for the sync browsing
pub fn toggle_sync_browsing(&mut self) { pub fn toggle_sync_browsing(&mut self) {
self.sync_browsing = !self.sync_browsing; self.sync_browsing = !self.sync_browsing;
} }
/// ### build_local_explorer
///
/// Build a file explorer with local host setup /// Build a file explorer with local host setup
pub fn build_local_explorer(cli: &ConfigClient) -> FileExplorer { pub fn build_local_explorer(cli: &ConfigClient) -> FileExplorer {
let mut builder = Self::build_explorer(cli); let mut builder = Self::build_explorer(cli);
@@ -144,8 +128,6 @@ impl Browser {
builder.build() builder.build()
} }
/// ### build_remote_explorer
///
/// Build a file explorer with remote host setup /// Build a file explorer with remote host setup
pub fn build_remote_explorer(cli: &ConfigClient) -> FileExplorer { pub fn build_remote_explorer(cli: &ConfigClient) -> FileExplorer {
let mut builder = Self::build_explorer(cli); let mut builder = Self::build_explorer(cli);
@@ -153,8 +135,6 @@ impl Browser {
builder.build() builder.build()
} }
/// ### build_explorer
///
/// Build explorer reading configuration from `ConfigClient` /// Build explorer reading configuration from `ConfigClient`
fn build_explorer(cli: &ConfigClient) -> FileExplorerBuilder { fn build_explorer(cli: &ConfigClient) -> FileExplorerBuilder {
let mut builder: FileExplorerBuilder = FileExplorerBuilder::new(); let mut builder: FileExplorerBuilder = FileExplorerBuilder::new();
@@ -167,8 +147,6 @@ impl Browser {
builder builder
} }
/// ### build_found_explorer
///
/// Build explorer reading from `ConfigClient`, for found result (has some differences) /// Build explorer reading from `ConfigClient`, for found result (has some differences)
fn build_found_explorer(wrkdir: &Path) -> FileExplorer { fn build_found_explorer(wrkdir: &Path) -> FileExplorer {
FileExplorerBuilder::new() FileExplorerBuilder::new()

View File

@@ -56,8 +56,6 @@ impl Default for TransferStates {
} }
impl TransferStates { impl TransferStates {
/// ### new
///
/// Instantiates a new transfer states /// Instantiates a new transfer states
pub fn new() -> TransferStates { pub fn new() -> TransferStates {
TransferStates { TransferStates {
@@ -67,29 +65,21 @@ impl TransferStates {
} }
} }
/// ### reset
///
/// Re-intiialize transfer states /// Re-intiialize transfer states
pub fn reset(&mut self) { pub fn reset(&mut self) {
self.aborted = false; self.aborted = false;
} }
/// ### abort
///
/// Set aborted to true /// Set aborted to true
pub fn abort(&mut self) { pub fn abort(&mut self) {
self.aborted = true; self.aborted = true;
} }
/// ### aborted
///
/// Returns whether transfer has been aborted /// Returns whether transfer has been aborted
pub fn aborted(&self) -> bool { pub fn aborted(&self) -> bool {
self.aborted self.aborted
} }
/// ### full_size
///
/// Returns the size of the entire transfer /// Returns the size of the entire transfer
pub fn full_size(&self) -> usize { pub fn full_size(&self) -> usize {
self.full.total self.full.total
@@ -128,8 +118,6 @@ impl fmt::Display for ProgressStates {
} }
impl ProgressStates { impl ProgressStates {
/// ### init
///
/// Initialize a new Progress State /// Initialize a new Progress State
pub fn init(&mut self, sz: usize) { pub fn init(&mut self, sz: usize) {
self.started = Instant::now(); self.started = Instant::now();
@@ -137,16 +125,12 @@ impl ProgressStates {
self.written = 0; self.written = 0;
} }
/// ### update_progress
///
/// Update progress state /// Update progress state
pub fn update_progress(&mut self, delta: usize) -> f64 { pub fn update_progress(&mut self, delta: usize) -> f64 {
self.written += delta; self.written += delta;
self.calc_progress_percentage() self.calc_progress_percentage()
} }
/// ### calc_progress
///
/// Calculate progress in a range between 0.0 to 1.0 /// Calculate progress in a range between 0.0 to 1.0
pub fn calc_progress(&self) -> f64 { pub fn calc_progress(&self) -> f64 {
// Prevent dividing by 0 // Prevent dividing by 0
@@ -160,22 +144,16 @@ impl ProgressStates {
} }
} }
/// ### started
///
/// Get started /// Get started
pub fn started(&self) -> Instant { pub fn started(&self) -> Instant {
self.started self.started
} }
/// ### calc_progress_percentage
///
/// Calculate the current transfer progress as percentage /// Calculate the current transfer progress as percentage
fn calc_progress_percentage(&self) -> f64 { fn calc_progress_percentage(&self) -> f64 {
self.calc_progress() * 100.0 self.calc_progress() * 100.0
} }
/// ### calc_bytes_per_second
///
/// Generic function to calculate bytes per second using elapsed time since transfer started and the bytes written /// Generic function to calculate bytes per second using elapsed time since transfer started and the bytes written
/// and the total amount of bytes to write /// and the total amount of bytes to write
pub fn calc_bytes_per_second(&self) -> u64 { pub fn calc_bytes_per_second(&self) -> u64 {
@@ -191,8 +169,6 @@ impl ProgressStates {
} }
} }
/// ### calc_eta
///
/// Calculate ETA for current transfer as seconds /// Calculate ETA for current transfer as seconds
fn calc_eta(&self) -> u64 { fn calc_eta(&self) -> u64 {
let elapsed_secs: u64 = self.started.elapsed().as_secs(); let elapsed_secs: u64 = self.started.elapsed().as_secs();
@@ -206,8 +182,6 @@ impl ProgressStates {
// -- Options // -- Options
/// ## TransferOpts
///
/// Defines the transfer options for transfer actions /// Defines the transfer options for transfer actions
pub struct TransferOpts { pub struct TransferOpts {
/// Save file as /// Save file as
@@ -226,16 +200,12 @@ impl Default for TransferOpts {
} }
impl TransferOpts { impl TransferOpts {
/// ### save_as
///
/// Define the name of the file to be saved /// Define the name of the file to be saved
pub fn save_as<S: AsRef<str>>(mut self, n: Option<S>) -> Self { pub fn save_as<S: AsRef<str>>(mut self, n: Option<S>) -> Self {
self.save_as = n.map(|x| x.as_ref().to_string()); self.save_as = n.map(|x| x.as_ref().to_string());
self self
} }
/// ### check_replace
///
/// Set whether to check if the file being transferred will "replace" an existing one /// Set whether to check if the file being transferred will "replace" an existing one
pub fn check_replace(mut self, opt: bool) -> Self { pub fn check_replace(mut self, opt: bool) -> Self {
self.check_replace = opt; self.check_replace = opt;

View File

@@ -43,8 +43,6 @@ use tuirealm::{PollStrategy, Update};
const LOG_CAPACITY: usize = 256; const LOG_CAPACITY: usize = 256;
impl FileTransferActivity { impl FileTransferActivity {
/// ### tick
///
/// Call `Application::tick()` and process messages in `Update` /// Call `Application::tick()` and process messages in `Update`
pub(super) fn tick(&mut self) { pub(super) fn tick(&mut self) {
match self.app.tick(PollStrategy::UpTo(3)) { match self.app.tick(PollStrategy::UpTo(3)) {
@@ -65,8 +63,6 @@ impl FileTransferActivity {
} }
} }
/// ### log
///
/// Add message to log events /// Add message to log events
pub(super) fn log(&mut self, level: LogLevel, msg: String) { pub(super) fn log(&mut self, level: LogLevel, msg: String) {
// Log to file // Log to file
@@ -87,8 +83,6 @@ impl FileTransferActivity {
self.update_logbox(); self.update_logbox();
} }
/// ### log_and_alert
///
/// Add message to log events and also display it as an alert /// Add message to log events and also display it as an alert
pub(super) fn log_and_alert(&mut self, level: LogLevel, msg: String) { pub(super) fn log_and_alert(&mut self, level: LogLevel, msg: String) {
self.mount_error(msg.as_str()); self.mount_error(msg.as_str());
@@ -97,8 +91,6 @@ impl FileTransferActivity {
self.update_logbox(); self.update_logbox();
} }
/// ### init_config_client
///
/// Initialize configuration client if possible. /// Initialize configuration client if possible.
/// This function doesn't return errors. /// This function doesn't return errors.
pub(super) fn init_config_client() -> ConfigClient { pub(super) fn init_config_client() -> ConfigClient {
@@ -119,29 +111,21 @@ impl FileTransferActivity {
} }
} }
/// ### setup_text_editor
///
/// Set text editor to use /// Set text editor to use
pub(super) fn setup_text_editor(&self) { pub(super) fn setup_text_editor(&self) {
env::set_var("EDITOR", self.config().get_text_editor()); env::set_var("EDITOR", self.config().get_text_editor());
} }
/// ### local_to_abs_path
///
/// Convert a path to absolute according to local explorer /// Convert a path to absolute according to local explorer
pub(super) fn local_to_abs_path(&self, path: &Path) -> PathBuf { pub(super) fn local_to_abs_path(&self, path: &Path) -> PathBuf {
path::absolutize(self.local().wrkdir.as_path(), path) path::absolutize(self.local().wrkdir.as_path(), path)
} }
/// ### remote_to_abs_path
///
/// Convert a path to absolute according to remote explorer /// Convert a path to absolute according to remote explorer
pub(super) fn remote_to_abs_path(&self, path: &Path) -> PathBuf { pub(super) fn remote_to_abs_path(&self, path: &Path) -> PathBuf {
path::absolutize(self.remote().wrkdir.as_path(), path) path::absolutize(self.remote().wrkdir.as_path(), path)
} }
/// ### get_remote_hostname
///
/// Get remote hostname /// Get remote hostname
pub(super) fn get_remote_hostname(&self) -> String { pub(super) fn get_remote_hostname(&self) -> String {
let ft_params = self.context().ft_params().unwrap(); let ft_params = self.context().ft_params().unwrap();
@@ -151,8 +135,6 @@ impl FileTransferActivity {
} }
} }
/// ### get_connection_msg
///
/// Get connection message to show to client /// Get connection message to show to client
pub(super) fn get_connection_msg(params: &ProtocolParams) -> String { pub(super) fn get_connection_msg(params: &ProtocolParams) -> String {
match params { match params {
@@ -173,8 +155,6 @@ impl FileTransferActivity {
} }
} }
/// ### notify_transfer_completed
///
/// Send notification regarding transfer completed /// Send notification regarding transfer completed
/// The notification is sent only when these conditions are satisfied: /// The notification is sent only when these conditions are satisfied:
/// ///
@@ -188,8 +168,6 @@ impl FileTransferActivity {
} }
} }
/// ### notify_transfer_error
///
/// Send notification regarding transfer error /// Send notification regarding transfer error
/// The notification is sent only when these conditions are satisfied: /// The notification is sent only when these conditions are satisfied:
/// ///
@@ -233,8 +211,6 @@ impl FileTransferActivity {
} }
} }
/// ### update_local_filelist
///
/// Update local file list /// Update local file list
pub(super) fn update_local_filelist(&mut self) { pub(super) fn update_local_filelist(&mut self) {
// Get width // Get width
@@ -280,8 +256,6 @@ impl FileTransferActivity {
.is_ok()); .is_ok());
} }
/// ### update_remote_filelist
///
/// Update remote file list /// Update remote file list
pub(super) fn update_remote_filelist(&mut self) { pub(super) fn update_remote_filelist(&mut self) {
let width: usize = self let width: usize = self
@@ -323,8 +297,6 @@ impl FileTransferActivity {
.is_ok()); .is_ok());
} }
/// ### update_logbox
///
/// Update log box /// Update log box
pub(super) fn update_logbox(&mut self) { pub(super) fn update_logbox(&mut self) {
let mut table: TableBuilder = TableBuilder::default(); let mut table: TableBuilder = TableBuilder::default();
@@ -418,8 +390,6 @@ impl FileTransferActivity {
.is_ok()); .is_ok());
} }
/// ### finalize_find
///
/// Finalize find process /// Finalize find process
pub(super) fn finalize_find(&mut self) { pub(super) fn finalize_find(&mut self) {
// Set found to none // Set found to none

View File

@@ -171,8 +171,6 @@ enum UiMsg {
ToggleSyncBrowsing, ToggleSyncBrowsing,
} }
/// ## LogLevel
///
/// Log level type /// Log level type
enum LogLevel { enum LogLevel {
Error, Error,
@@ -180,8 +178,6 @@ enum LogLevel {
Info, Info,
} }
/// ## LogRecord
///
/// Log record entry /// Log record entry
struct LogRecord { struct LogRecord {
pub time: DateTime<Local>, pub time: DateTime<Local>,
@@ -190,8 +186,6 @@ struct LogRecord {
} }
impl LogRecord { impl LogRecord {
/// ### new
///
/// Instantiates a new LogRecord /// Instantiates a new LogRecord
pub fn new(level: LogLevel, msg: String) -> LogRecord { pub fn new(level: LogLevel, msg: String) -> LogRecord {
LogRecord { LogRecord {
@@ -202,8 +196,6 @@ impl LogRecord {
} }
} }
/// ## FileTransferActivity
///
/// FileTransferActivity is the data holder for the file transfer activity /// FileTransferActivity is the data holder for the file transfer activity
pub struct FileTransferActivity { pub struct FileTransferActivity {
/// Exit reason /// Exit reason
@@ -228,8 +220,6 @@ pub struct FileTransferActivity {
} }
impl FileTransferActivity { impl FileTransferActivity {
/// ### new
///
/// Instantiates a new FileTransferActivity /// Instantiates a new FileTransferActivity
pub fn new(host: Localhost, params: &FileTransferParams, ticks: Duration) -> Self { pub fn new(host: Localhost, params: &FileTransferParams, ticks: Duration) -> Self {
// Get config client // Get config client
@@ -279,8 +269,6 @@ impl FileTransferActivity {
self.browser.found_mut() self.browser.found_mut()
} }
/// ### get_cache_tmp_name
///
/// Get file name for a file in cache /// Get file name for a file in cache
fn get_cache_tmp_name(&self, name: &str, file_type: Option<&str>) -> Option<String> { fn get_cache_tmp_name(&self, name: &str, file_type: Option<&str>) -> Option<String> {
self.cache.as_ref().map(|_| { self.cache.as_ref().map(|_| {
@@ -299,29 +287,21 @@ impl FileTransferActivity {
}) })
} }
/// ### context
///
/// Returns a reference to context /// Returns a reference to context
fn context(&self) -> &Context { fn context(&self) -> &Context {
self.context.as_ref().unwrap() self.context.as_ref().unwrap()
} }
/// ### context_mut
///
/// Returns a mutable reference to context /// Returns a mutable reference to context
fn context_mut(&mut self) -> &mut Context { fn context_mut(&mut self) -> &mut Context {
self.context.as_mut().unwrap() self.context.as_mut().unwrap()
} }
/// ### config
///
/// Returns config client reference /// Returns config client reference
fn config(&self) -> &ConfigClient { fn config(&self) -> &ConfigClient {
self.context().config() self.context().config()
} }
/// ### theme
///
/// Get a reference to `Theme` /// Get a reference to `Theme`
fn theme(&self) -> &Theme { fn theme(&self) -> &Theme {
self.context().theme_provider().theme() self.context().theme_provider().theme()
@@ -335,8 +315,6 @@ impl FileTransferActivity {
*/ */
impl Activity for FileTransferActivity { impl Activity for FileTransferActivity {
/// ### on_create
///
/// `on_create` is the function which must be called to initialize the activity. /// `on_create` is the function which must be called to initialize the activity.
/// `on_create` must initialize all the data structures used by the activity /// `on_create` must initialize all the data structures used by the activity
fn on_create(&mut self, context: Context) { fn on_create(&mut self, context: Context) {
@@ -368,8 +346,6 @@ impl Activity for FileTransferActivity {
info!("Created FileTransferActivity"); info!("Created FileTransferActivity");
} }
/// ### on_draw
///
/// `on_draw` is the function which draws the graphical interface. /// `on_draw` is the function which draws the graphical interface.
/// This function must be called at each tick to refresh the interface /// This function must be called at each tick to refresh the interface
fn on_draw(&mut self) { fn on_draw(&mut self) {
@@ -398,8 +374,6 @@ impl Activity for FileTransferActivity {
} }
} }
/// ### will_umount
///
/// `will_umount` is the method which must be able to report to the activity manager, whether /// `will_umount` is the method which must be able to report to the activity manager, whether
/// the activity should be terminated or not. /// the activity should be terminated or not.
/// If not, the call will return `None`, otherwise return`Some(ExitReason)` /// If not, the call will return `None`, otherwise return`Some(ExitReason)`
@@ -407,8 +381,6 @@ impl Activity for FileTransferActivity {
self.exit_reason.as_ref() self.exit_reason.as_ref()
} }
/// ### on_destroy
///
/// `on_destroy` is the function which cleans up runtime variables and data before terminating the activity. /// `on_destroy` is the function which cleans up runtime variables and data before terminating the activity.
/// This function must be called once before terminating the activity. /// This function must be called once before terminating the activity.
fn on_destroy(&mut self) -> Option<Context> { fn on_destroy(&mut self) -> Option<Context> {

View File

@@ -40,8 +40,6 @@ use std::path::{Path, PathBuf};
use std::time::Instant; use std::time::Instant;
use thiserror::Error; use thiserror::Error;
/// ## TransferErrorReason
///
/// Describes the reason that caused an error during a file transfer /// Describes the reason that caused an error during a file transfer
#[derive(Error, Debug)] #[derive(Error, Debug)]
enum TransferErrorReason { enum TransferErrorReason {
@@ -59,8 +57,6 @@ enum TransferErrorReason {
FileTransferError(RemoteError), FileTransferError(RemoteError),
} }
/// ## TransferPayload
///
/// Represents the entity to send or receive during a transfer. /// Represents the entity to send or receive during a transfer.
/// - File: describes an individual `File` to send /// - File: describes an individual `File` to send
/// - Any: Can be any kind of `Entry`, but just one /// - Any: Can be any kind of `Entry`, but just one
@@ -73,8 +69,6 @@ pub(super) enum TransferPayload {
} }
impl FileTransferActivity { impl FileTransferActivity {
/// ### connect
///
/// Connect to remote /// Connect to remote
pub(super) fn connect(&mut self) { pub(super) fn connect(&mut self) {
let ft_params = self.context().ft_params().unwrap().clone(); let ft_params = self.context().ft_params().unwrap().clone();
@@ -116,8 +110,6 @@ impl FileTransferActivity {
} }
} }
/// ### disconnect
///
/// disconnect from remote /// disconnect from remote
pub(super) fn disconnect(&mut self) { pub(super) fn disconnect(&mut self) {
let msg: String = format!("Disconnecting from {}", self.get_remote_hostname()); let msg: String = format!("Disconnecting from {}", self.get_remote_hostname());
@@ -129,16 +121,12 @@ impl FileTransferActivity {
self.exit_reason = Some(super::ExitReason::Disconnect); self.exit_reason = Some(super::ExitReason::Disconnect);
} }
/// ### disconnect_and_quit
///
/// disconnect from remote and then quit /// disconnect from remote and then quit
pub(super) fn disconnect_and_quit(&mut self) { pub(super) fn disconnect_and_quit(&mut self) {
self.disconnect(); self.disconnect();
self.exit_reason = Some(super::ExitReason::Quit); self.exit_reason = Some(super::ExitReason::Quit);
} }
/// ### reload_remote_dir
///
/// Reload remote directory entries and update browser /// Reload remote directory entries and update browser
pub(super) fn reload_remote_dir(&mut self) { pub(super) fn reload_remote_dir(&mut self) {
// Get current entries // Get current entries
@@ -149,8 +137,6 @@ impl FileTransferActivity {
} }
} }
/// ### reload_local_dir
///
/// Reload local directory entries and update browser /// Reload local directory entries and update browser
pub(super) fn reload_local_dir(&mut self) { pub(super) fn reload_local_dir(&mut self) {
let wrkdir: PathBuf = self.host.pwd(); let wrkdir: PathBuf = self.host.pwd();
@@ -158,8 +144,6 @@ impl FileTransferActivity {
self.local_mut().wrkdir = wrkdir; self.local_mut().wrkdir = wrkdir;
} }
/// ### local_scan
///
/// Scan current local directory /// Scan current local directory
fn local_scan(&mut self, path: &Path) { fn local_scan(&mut self, path: &Path) {
match self.host.scan_dir(path) { match self.host.scan_dir(path) {
@@ -176,8 +160,6 @@ impl FileTransferActivity {
} }
} }
/// ### remote_scan
///
/// Scan current remote directory /// Scan current remote directory
fn remote_scan(&mut self, path: &Path) { fn remote_scan(&mut self, path: &Path) {
match self.client.list_dir(path) { match self.client.list_dir(path) {
@@ -194,8 +176,6 @@ impl FileTransferActivity {
} }
} }
/// ### filetransfer_send
///
/// Send fs entry to remote. /// Send fs entry to remote.
/// If dst_name is Some, entry will be saved with a different name. /// If dst_name is Some, entry will be saved with a different name.
/// If entry is a directory, this applies to directory only /// If entry is a directory, this applies to directory only
@@ -229,8 +209,6 @@ impl FileTransferActivity {
result result
} }
/// ### filetransfer_send_file
///
/// Send one file to remote at specified path. /// Send one file to remote at specified path.
fn filetransfer_send_file( fn filetransfer_send_file(
&mut self, &mut self,
@@ -261,8 +239,6 @@ impl FileTransferActivity {
result.map_err(|x| x.to_string()) result.map_err(|x| x.to_string())
} }
/// ### filetransfer_send_any
///
/// Send a `TransferPayload` of type `Any` /// Send a `TransferPayload` of type `Any`
fn filetransfer_send_any( fn filetransfer_send_any(
&mut self, &mut self,
@@ -284,8 +260,6 @@ impl FileTransferActivity {
result result
} }
/// ### filetransfer_send_many
///
/// Send many entries to remote /// Send many entries to remote
fn filetransfer_send_many( fn filetransfer_send_many(
&mut self, &mut self,
@@ -448,8 +422,6 @@ impl FileTransferActivity {
result result
} }
/// ### filetransfer_send_file
///
/// Send local file and write it to remote path /// Send local file and write it to remote path
fn filetransfer_send_one( fn filetransfer_send_one(
&mut self, &mut self,
@@ -479,8 +451,6 @@ impl FileTransferActivity {
} }
} }
/// ### filetransfer_send_one_with_stream
///
/// Send file to remote using stream /// Send file to remote using stream
fn filetransfer_send_one_with_stream( fn filetransfer_send_one_with_stream(
&mut self, &mut self,
@@ -580,8 +550,6 @@ impl FileTransferActivity {
Ok(()) Ok(())
} }
/// ### filetransfer_send_one_wno_stream
///
/// Send an `File` to remote without using streams. /// Send an `File` to remote without using streams.
fn filetransfer_send_one_wno_stream( fn filetransfer_send_one_wno_stream(
&mut self, &mut self,
@@ -631,8 +599,6 @@ impl FileTransferActivity {
Ok(()) Ok(())
} }
/// ### filetransfer_recv
///
/// Recv fs entry from remote. /// Recv fs entry from remote.
/// If dst_name is Some, entry will be saved with a different name. /// If dst_name is Some, entry will be saved with a different name.
/// If entry is a directory, this applies to directory only /// If entry is a directory, this applies to directory only
@@ -661,8 +627,6 @@ impl FileTransferActivity {
result result
} }
/// ### filetransfer_recv_any
///
/// Recv fs entry from remote. /// Recv fs entry from remote.
/// If dst_name is Some, entry will be saved with a different name. /// If dst_name is Some, entry will be saved with a different name.
/// If entry is a directory, this applies to directory only /// If entry is a directory, this applies to directory only
@@ -686,8 +650,6 @@ impl FileTransferActivity {
result result
} }
/// ### filetransfer_recv_file
///
/// Receive a single file from remote. /// Receive a single file from remote.
fn filetransfer_recv_file(&mut self, entry: &File, local_path: &Path) -> Result<(), String> { fn filetransfer_recv_file(&mut self, entry: &File, local_path: &Path) -> Result<(), String> {
// Reset states // Reset states
@@ -705,8 +667,6 @@ impl FileTransferActivity {
result.map_err(|x| x.to_string()) result.map_err(|x| x.to_string())
} }
/// ### filetransfer_send_many
///
/// Send many entries to remote /// Send many entries to remote
fn filetransfer_recv_many( fn filetransfer_recv_many(
&mut self, &mut self,
@@ -887,8 +847,6 @@ impl FileTransferActivity {
result result
} }
/// ### filetransfer_recv_one
///
/// Receive file from remote and write it to local path /// Receive file from remote and write it to local path
fn filetransfer_recv_one( fn filetransfer_recv_one(
&mut self, &mut self,
@@ -914,8 +872,6 @@ impl FileTransferActivity {
} }
} }
/// ### filetransfer_recv_one_with_stream
///
/// Receive an `Entry` from remote using stream /// Receive an `Entry` from remote using stream
fn filetransfer_recv_one_with_stream( fn filetransfer_recv_one_with_stream(
&mut self, &mut self,
@@ -1023,8 +979,6 @@ impl FileTransferActivity {
Ok(()) Ok(())
} }
/// ### filetransfer_recv_one_with_stream
///
/// Receive an `Entry` from remote without using stream /// Receive an `Entry` from remote without using stream
fn filetransfer_recv_one_wno_stream( fn filetransfer_recv_one_wno_stream(
&mut self, &mut self,
@@ -1086,8 +1040,6 @@ impl FileTransferActivity {
Ok(()) Ok(())
} }
/// ### local_changedir
///
/// Change directory for local /// Change directory for local
pub(super) fn local_changedir(&mut self, path: &Path, push: bool) { pub(super) fn local_changedir(&mut self, path: &Path, push: bool) {
// Get current directory // Get current directory
@@ -1143,8 +1095,6 @@ impl FileTransferActivity {
} }
} }
/// ### download_file_as_temp
///
/// Download provided file as a temporary file /// Download provided file as a temporary file
pub(super) fn download_file_as_temp(&mut self, file: &File) -> Result<PathBuf, String> { pub(super) fn download_file_as_temp(&mut self, file: &File) -> Result<PathBuf, String> {
let tmpfile: PathBuf = match self.cache.as_ref() { let tmpfile: PathBuf = match self.cache.as_ref() {
@@ -1176,8 +1126,6 @@ impl FileTransferActivity {
// -- transfer sizes // -- transfer sizes
/// ### get_total_transfer_size_local
///
/// Get total size of transfer for localhost /// Get total size of transfer for localhost
fn get_total_transfer_size_local(&mut self, entry: &Entry) -> usize { fn get_total_transfer_size_local(&mut self, entry: &Entry) -> usize {
match entry { match entry {
@@ -1201,8 +1149,6 @@ impl FileTransferActivity {
} }
} }
/// ### get_total_transfer_size_remote
///
/// Get total size of transfer for remote host /// Get total size of transfer for remote host
fn get_total_transfer_size_remote(&mut self, entry: &Entry) -> usize { fn get_total_transfer_size_remote(&mut self, entry: &Entry) -> usize {
match entry { match entry {

View File

@@ -43,8 +43,6 @@ use tuirealm::{Sub, SubClause, SubEventClause};
impl FileTransferActivity { impl FileTransferActivity {
// -- init // -- init
/// ### init
///
/// Initialize file transfer activity's view /// Initialize file transfer activity's view
pub(super) fn init(&mut self) { pub(super) fn init(&mut self) {
// Mount local file explorer // Mount local file explorer
@@ -106,8 +104,6 @@ impl FileTransferActivity {
// -- view // -- view
/// ### view
///
/// View gui /// View gui
pub(super) fn view(&mut self) { pub(super) fn view(&mut self) {
self.redraw = false; self.redraw = false;
@@ -303,8 +299,6 @@ impl FileTransferActivity {
// -- partials // -- partials
/// ### mount_info
///
/// Mount info box /// Mount info box
pub(super) fn mount_info<S: AsRef<str>>(&mut self, text: S) { pub(super) fn mount_info<S: AsRef<str>>(&mut self, text: S) {
// Mount // Mount
@@ -320,8 +314,6 @@ impl FileTransferActivity {
assert!(self.app.active(&Id::ErrorPopup).is_ok()); assert!(self.app.active(&Id::ErrorPopup).is_ok());
} }
/// ### mount_error
///
/// Mount error box /// Mount error box
pub(super) fn mount_error<S: AsRef<str>>(&mut self, text: S) { pub(super) fn mount_error<S: AsRef<str>>(&mut self, text: S) {
// Mount // Mount
@@ -337,8 +329,6 @@ impl FileTransferActivity {
assert!(self.app.active(&Id::ErrorPopup).is_ok()); assert!(self.app.active(&Id::ErrorPopup).is_ok());
} }
/// ### umount_error
///
/// Umount error message /// Umount error message
pub(super) fn umount_error(&mut self) { pub(super) fn umount_error(&mut self) {
let _ = self.app.umount(&Id::ErrorPopup); let _ = self.app.umount(&Id::ErrorPopup);
@@ -358,8 +348,6 @@ impl FileTransferActivity {
assert!(self.app.active(&Id::FatalPopup).is_ok()); assert!(self.app.active(&Id::FatalPopup).is_ok());
} }
/// ### umount_fatal
///
/// Umount fatal error message /// Umount fatal error message
pub(super) fn umount_fatal(&mut self) { pub(super) fn umount_fatal(&mut self) {
let _ = self.app.umount(&Id::FatalPopup); let _ = self.app.umount(&Id::FatalPopup);
@@ -387,8 +375,6 @@ impl FileTransferActivity {
let _ = self.app.umount(&Id::WaitPopup); let _ = self.app.umount(&Id::WaitPopup);
} }
/// ### mount_quit
///
/// Mount quit popup /// Mount quit popup
pub(super) fn mount_quit(&mut self) { pub(super) fn mount_quit(&mut self) {
// Protocol // Protocol
@@ -404,15 +390,11 @@ impl FileTransferActivity {
assert!(self.app.active(&Id::QuitPopup).is_ok()); assert!(self.app.active(&Id::QuitPopup).is_ok());
} }
/// ### umount_quit
///
/// Umount quit popup /// Umount quit popup
pub(super) fn umount_quit(&mut self) { pub(super) fn umount_quit(&mut self) {
let _ = self.app.umount(&Id::QuitPopup); let _ = self.app.umount(&Id::QuitPopup);
} }
/// ### mount_disconnect
///
/// Mount disconnect popup /// Mount disconnect popup
pub(super) fn mount_disconnect(&mut self) { pub(super) fn mount_disconnect(&mut self) {
// Protocol // Protocol
@@ -428,8 +410,6 @@ impl FileTransferActivity {
assert!(self.app.active(&Id::DisconnectPopup).is_ok()); assert!(self.app.active(&Id::DisconnectPopup).is_ok());
} }
/// ### umount_disconnect
///
/// Umount disconnect popup /// Umount disconnect popup
pub(super) fn umount_disconnect(&mut self) { pub(super) fn umount_disconnect(&mut self) {
let _ = self.app.umount(&Id::DisconnectPopup); let _ = self.app.umount(&Id::DisconnectPopup);
@@ -735,8 +715,6 @@ impl FileTransferActivity {
assert!(self.app.active(&Id::ReplacePopup).is_ok()); assert!(self.app.active(&Id::ReplacePopup).is_ok());
} }
/// ### is_radio_replace_extended
///
/// Returns whether radio replace is in "extended" mode (for many files) /// Returns whether radio replace is in "extended" mode (for many files)
pub(super) fn is_radio_replace_extended(&self) -> bool { pub(super) fn is_radio_replace_extended(&self) -> bool {
self.app.mounted(&Id::ReplacingFilesListPopup) self.app.mounted(&Id::ReplacingFilesListPopup)
@@ -799,8 +777,6 @@ impl FileTransferActivity {
.is_ok()); .is_ok());
} }
/// ### mount_help
///
/// Mount help /// Mount help
pub(super) fn mount_help(&mut self) { pub(super) fn mount_help(&mut self) {
let key_color = self.theme().misc_keys; let key_color = self.theme().misc_keys;
@@ -852,8 +828,6 @@ impl FileTransferActivity {
.is_ok()); .is_ok());
} }
/// ### no_popup_mounted_clause
///
/// Returns a sub clause which requires that no popup is mounted in order to be satisfied /// Returns a sub clause which requires that no popup is mounted in order to be satisfied
fn no_popup_mounted_clause() -> SubClause<Id> { fn no_popup_mounted_clause() -> SubClause<Id> {
SubClause::And( SubClause::And(

View File

@@ -45,28 +45,20 @@ pub enum ExitReason {
// -- Activity trait // -- Activity trait
pub trait Activity { pub trait Activity {
/// ### on_create
///
/// `on_create` is the function which must be called to initialize the activity. /// `on_create` is the function which must be called to initialize the activity.
/// `on_create` must initialize all the data structures used by the activity /// `on_create` must initialize all the data structures used by the activity
/// Context is taken from activity manager and will be released only when activity is destroyed /// Context is taken from activity manager and will be released only when activity is destroyed
fn on_create(&mut self, context: Context); fn on_create(&mut self, context: Context);
/// ### on_draw
///
/// `on_draw` is the function which draws the graphical interface. /// `on_draw` is the function which draws the graphical interface.
/// This function must be called at each tick to refresh the interface /// This function must be called at each tick to refresh the interface
fn on_draw(&mut self); fn on_draw(&mut self);
/// ### will_umount
///
/// `will_umount` is the method which must be able to report to the activity manager, whether /// `will_umount` is the method which must be able to report to the activity manager, whether
/// the activity should be terminated or not. /// the activity should be terminated or not.
/// If not, the call will return `None`, otherwise return`Some(ExitReason)` /// If not, the call will return `None`, otherwise return`Some(ExitReason)`
fn will_umount(&self) -> Option<&ExitReason>; fn will_umount(&self) -> Option<&ExitReason>;
/// ### on_destroy
///
/// `on_destroy` is the function which cleans up runtime variables and data before terminating the activity. /// `on_destroy` is the function which cleans up runtime variables and data before terminating the activity.
/// This function must be called once before terminating the activity. /// This function must be called once before terminating the activity.
/// This function finally releases the context /// This function finally releases the context

View File

@@ -35,8 +35,6 @@ use tuirealm::tui::style::Color;
use tuirealm::{State, StateValue}; use tuirealm::{State, StateValue};
impl SetupActivity { impl SetupActivity {
/// ### action_on_esc
///
/// On <ESC>, if there are changes in the configuration, the quit dialog must be shown, otherwise /// On <ESC>, if there are changes in the configuration, the quit dialog must be shown, otherwise
/// we can exit without any problem /// we can exit without any problem
pub(super) fn action_on_esc(&mut self) { pub(super) fn action_on_esc(&mut self) {
@@ -47,8 +45,6 @@ impl SetupActivity {
} }
} }
/// ### action_save_all
///
/// Save all configurations. If current tab can load values, they will be loaded, otherwise they'll just be saved. /// Save all configurations. If current tab can load values, they will be loaded, otherwise they'll just be saved.
/// Once all the configuration has been changed, set config_changed to false /// Once all the configuration has been changed, set config_changed to false
pub(super) fn action_save_all(&mut self) -> Result<(), String> { pub(super) fn action_save_all(&mut self) -> Result<(), String> {
@@ -59,8 +55,6 @@ impl SetupActivity {
Ok(()) Ok(())
} }
/// ### action_save_config
///
/// Save configuration /// Save configuration
fn action_save_config(&mut self) -> Result<(), String> { fn action_save_config(&mut self) -> Result<(), String> {
// Collect input values if in setup form // Collect input values if in setup form
@@ -70,8 +64,6 @@ impl SetupActivity {
self.save_config() self.save_config()
} }
/// ### action_save_theme
///
/// Save configuration /// Save configuration
fn action_save_theme(&mut self) -> Result<(), String> { fn action_save_theme(&mut self) -> Result<(), String> {
// Collect input values if in theme form // Collect input values if in theme form
@@ -83,8 +75,6 @@ impl SetupActivity {
self.save_theme() self.save_theme()
} }
/// ### action_change_tab
///
/// Change view tab and load input values in order not to lose them /// Change view tab and load input values in order not to lose them
pub(super) fn action_change_tab(&mut self, new_tab: ViewLayout) -> Result<(), String> { pub(super) fn action_change_tab(&mut self, new_tab: ViewLayout) -> Result<(), String> {
// load values for current tab first // load values for current tab first
@@ -100,8 +90,6 @@ impl SetupActivity {
Ok(()) Ok(())
} }
/// ### action_reset_config
///
/// Reset configuration input fields /// Reset configuration input fields
pub(super) fn action_reset_config(&mut self) -> Result<(), String> { pub(super) fn action_reset_config(&mut self) -> Result<(), String> {
match self.reset_config_changes() { match self.reset_config_changes() {
@@ -113,8 +101,6 @@ impl SetupActivity {
} }
} }
/// ### action_reset_theme
///
/// Reset configuration input fields /// Reset configuration input fields
pub(super) fn action_reset_theme(&mut self) -> Result<(), String> { pub(super) fn action_reset_theme(&mut self) -> Result<(), String> {
match self.reset_theme_changes() { match self.reset_theme_changes() {
@@ -126,8 +112,6 @@ impl SetupActivity {
} }
} }
/// ### action_delete_ssh_key
///
/// delete of a ssh key /// delete of a ssh key
pub(super) fn action_delete_ssh_key(&mut self) { pub(super) fn action_delete_ssh_key(&mut self) {
// Get key // Get key
@@ -160,8 +144,6 @@ impl SetupActivity {
} }
} }
/// ### action_new_ssh_key
///
/// Create a new ssh key /// Create a new ssh key
pub(super) fn action_new_ssh_key(&mut self) { pub(super) fn action_new_ssh_key(&mut self) {
// get parameters // get parameters
@@ -228,8 +210,6 @@ impl SetupActivity {
} }
} }
/// ### set_color
///
/// Given a component and a color, save the color into the theme /// Given a component and a color, save the color into the theme
pub(super) fn action_save_color(&mut self, component: IdTheme, color: Color) { pub(super) fn action_save_color(&mut self, component: IdTheme, color: Color) {
let theme: &mut Theme = self.theme_mut(); let theme: &mut Theme = self.theme_mut();
@@ -319,8 +299,6 @@ impl SetupActivity {
} }
} }
/// ### collect_styles
///
/// Collect values from input and put them into the theme. /// Collect values from input and put them into the theme.
/// If a component has an invalid color, returns Err(component_id) /// If a component has an invalid color, returns Err(component_id)
fn collect_styles(&mut self) -> Result<(), Id> { fn collect_styles(&mut self) -> Result<(), Id> {
@@ -440,8 +418,6 @@ impl SetupActivity {
Ok(()) Ok(())
} }
/// ### get_color
///
/// Get color from component /// Get color from component
fn get_color(&self, component: &Id) -> Result<Color, ()> { fn get_color(&self, component: &Id) -> Result<Color, ()> {
match self.app.state(component) { match self.app.state(component) {

View File

@@ -32,8 +32,6 @@ use super::SetupActivity;
use std::env; use std::env;
impl SetupActivity { impl SetupActivity {
/// ### save_config
///
/// Save configuration /// Save configuration
pub(super) fn save_config(&mut self) -> Result<(), String> { pub(super) fn save_config(&mut self) -> Result<(), String> {
match self.config().write_config() { match self.config().write_config() {
@@ -42,8 +40,6 @@ impl SetupActivity {
} }
} }
/// ### reset_config_changes
///
/// Reset configuration changes; pratically read config from file, overwriting any change made /// Reset configuration changes; pratically read config from file, overwriting any change made
/// since last write action /// since last write action
pub(super) fn reset_config_changes(&mut self) -> Result<(), String> { pub(super) fn reset_config_changes(&mut self) -> Result<(), String> {
@@ -52,8 +48,6 @@ impl SetupActivity {
.map_err(|e| format!("Could not reload configuration: {}", e)) .map_err(|e| format!("Could not reload configuration: {}", e))
} }
/// ### save_theme
///
/// Save theme to file /// Save theme to file
pub(super) fn save_theme(&mut self) -> Result<(), String> { pub(super) fn save_theme(&mut self) -> Result<(), String> {
self.theme_provider() self.theme_provider()
@@ -61,8 +55,6 @@ impl SetupActivity {
.map_err(|e| format!("Could not save theme: {}", e)) .map_err(|e| format!("Could not save theme: {}", e))
} }
/// ### reset_theme_changes
///
/// Reset changes committed to theme /// Reset changes committed to theme
pub(super) fn reset_theme_changes(&mut self) -> Result<(), String> { pub(super) fn reset_theme_changes(&mut self) -> Result<(), String> {
self.theme_provider() self.theme_provider()
@@ -70,8 +62,6 @@ impl SetupActivity {
.map_err(|e| format!("Could not restore theme: {}", e)) .map_err(|e| format!("Could not restore theme: {}", e))
} }
/// ### delete_ssh_key
///
/// Delete ssh key from config cli /// Delete ssh key from config cli
pub(super) fn delete_ssh_key(&mut self, host: &str, username: &str) -> Result<(), String> { pub(super) fn delete_ssh_key(&mut self, host: &str, username: &str) -> Result<(), String> {
match self.config_mut().del_ssh_key(host, username) { match self.config_mut().del_ssh_key(host, username) {
@@ -83,8 +73,6 @@ impl SetupActivity {
} }
} }
/// ### edit_ssh_key
///
/// Edit selected ssh key /// Edit selected ssh key
pub(super) fn edit_ssh_key(&mut self, idx: usize) -> Result<(), String> { pub(super) fn edit_ssh_key(&mut self, idx: usize) -> Result<(), String> {
match self.context.as_mut() { match self.context.as_mut() {
@@ -142,8 +130,6 @@ impl SetupActivity {
} }
} }
/// ### add_ssh_key
///
/// Add provided ssh key to config client /// Add provided ssh key to config client
pub(super) fn add_ssh_key( pub(super) fn add_ssh_key(
&mut self, &mut self,

View File

@@ -256,8 +256,6 @@ pub enum ViewLayout {
Theme, Theme,
} }
/// ## SetupActivity
///
/// Setup activity states holder /// Setup activity states holder
pub struct SetupActivity { pub struct SetupActivity {
app: Application<Id, Msg, NoUserEvent>, app: Application<Id, Msg, NoUserEvent>,
@@ -282,15 +280,11 @@ impl SetupActivity {
} }
} }
/// ### context
///
/// Returns a reference to context /// Returns a reference to context
fn context(&self) -> &Context { fn context(&self) -> &Context {
self.context.as_ref().unwrap() self.context.as_ref().unwrap()
} }
/// ### context_mut
///
/// Returns a mutable reference to context /// Returns a mutable reference to context
fn context_mut(&mut self) -> &mut Context { fn context_mut(&mut self) -> &mut Context {
self.context.as_mut().unwrap() self.context.as_mut().unwrap()
@@ -316,8 +310,6 @@ impl SetupActivity {
self.context_mut().theme_provider_mut() self.context_mut().theme_provider_mut()
} }
/// ### config_changed
///
/// Returns whether config has changed /// Returns whether config has changed
fn config_changed(&self) -> bool { fn config_changed(&self) -> bool {
self.context() self.context()
@@ -326,8 +318,6 @@ impl SetupActivity {
.unwrap_or(false) .unwrap_or(false)
} }
/// ### set_config_changed
///
/// Set value for config changed key into the store /// Set value for config changed key into the store
fn set_config_changed(&mut self, changed: bool) { fn set_config_changed(&mut self, changed: bool) {
self.context_mut() self.context_mut()
@@ -337,8 +327,6 @@ impl SetupActivity {
} }
impl Activity for SetupActivity { impl Activity for SetupActivity {
/// ### on_create
///
/// `on_create` is the function which must be called to initialize the activity. /// `on_create` is the function which must be called to initialize the activity.
/// `on_create` must initialize all the data structures used by the activity /// `on_create` must initialize all the data structures used by the activity
/// Context is taken from activity manager and will be released only when activity is destroyed /// Context is taken from activity manager and will be released only when activity is destroyed
@@ -363,8 +351,6 @@ impl Activity for SetupActivity {
} }
} }
/// ### on_draw
///
/// `on_draw` is the function which draws the graphical interface. /// `on_draw` is the function which draws the graphical interface.
/// This function must be called at each tick to refresh the interface /// This function must be called at each tick to refresh the interface
fn on_draw(&mut self) { fn on_draw(&mut self) {
@@ -394,8 +380,6 @@ impl Activity for SetupActivity {
} }
} }
/// ### will_umount
///
/// `will_umount` is the method which must be able to report to the activity manager, whether /// `will_umount` is the method which must be able to report to the activity manager, whether
/// the activity should be terminated or not. /// the activity should be terminated or not.
/// If not, the call will return `None`, otherwise return`Some(ExitReason)` /// If not, the call will return `None`, otherwise return`Some(ExitReason)`
@@ -403,8 +387,6 @@ impl Activity for SetupActivity {
self.exit_reason.as_ref() self.exit_reason.as_ref()
} }
/// ### on_destroy
///
/// `on_destroy` is the function which cleans up runtime variables and data before terminating the activity. /// `on_destroy` is the function which cleans up runtime variables and data before terminating the activity.
/// This function must be called once before terminating the activity. /// This function must be called once before terminating the activity.
/// This function finally releases the context /// This function finally releases the context

View File

@@ -36,8 +36,6 @@ use super::{
use tuirealm::Update; use tuirealm::Update;
impl Update<Msg> for SetupActivity { impl Update<Msg> for SetupActivity {
/// ### update
///
/// Update auth activity model based on msg /// Update auth activity model based on msg
/// The function exits when returns None /// The function exits when returns None
fn update(&mut self, msg: Option<Msg>) -> Option<Msg> { fn update(&mut self, msg: Option<Msg>) -> Option<Msg> {

View File

@@ -54,8 +54,6 @@ impl SetupActivity {
} }
} }
/// ### view
///
/// View gui /// View gui
pub(super) fn view(&mut self) { pub(super) fn view(&mut self) {
self.redraw = false; self.redraw = false;
@@ -68,8 +66,6 @@ impl SetupActivity {
// -- mount // -- mount
/// ### mount_error
///
/// Mount error box /// Mount error box
pub(super) fn mount_error<S: AsRef<str>>(&mut self, text: S) { pub(super) fn mount_error<S: AsRef<str>>(&mut self, text: S) {
assert!(self assert!(self
@@ -83,15 +79,11 @@ impl SetupActivity {
assert!(self.app.active(&Id::Common(IdCommon::ErrorPopup)).is_ok()); assert!(self.app.active(&Id::Common(IdCommon::ErrorPopup)).is_ok());
} }
/// ### umount_error
///
/// Umount error message /// Umount error message
pub(super) fn umount_error(&mut self) { pub(super) fn umount_error(&mut self) {
let _ = self.app.umount(&Id::Common(IdCommon::ErrorPopup)); let _ = self.app.umount(&Id::Common(IdCommon::ErrorPopup));
} }
/// ### mount_quit
///
/// Mount quit popup /// Mount quit popup
pub(super) fn mount_quit(&mut self) { pub(super) fn mount_quit(&mut self) {
assert!(self assert!(self
@@ -105,15 +97,11 @@ impl SetupActivity {
assert!(self.app.active(&Id::Common(IdCommon::QuitPopup)).is_ok()); assert!(self.app.active(&Id::Common(IdCommon::QuitPopup)).is_ok());
} }
/// ### umount_quit
///
/// Umount quit /// Umount quit
pub(super) fn umount_quit(&mut self) { pub(super) fn umount_quit(&mut self) {
let _ = self.app.umount(&Id::Common(IdCommon::QuitPopup)); let _ = self.app.umount(&Id::Common(IdCommon::QuitPopup));
} }
/// ### mount_save_popup
///
/// Mount save popup /// Mount save popup
pub(super) fn mount_save_popup(&mut self) { pub(super) fn mount_save_popup(&mut self) {
assert!(self assert!(self
@@ -127,15 +115,11 @@ impl SetupActivity {
assert!(self.app.active(&Id::Common(IdCommon::SavePopup)).is_ok()); assert!(self.app.active(&Id::Common(IdCommon::SavePopup)).is_ok());
} }
/// ### umount_quit
///
/// Umount quit /// Umount quit
pub(super) fn umount_save_popup(&mut self) { pub(super) fn umount_save_popup(&mut self) {
let _ = self.app.umount(&Id::Common(IdCommon::SavePopup)); let _ = self.app.umount(&Id::Common(IdCommon::SavePopup));
} }
/// ### mount_help
///
/// Mount help /// Mount help
pub(super) fn mount_help(&mut self) { pub(super) fn mount_help(&mut self) {
assert!(self assert!(self
@@ -149,8 +133,6 @@ impl SetupActivity {
assert!(self.app.active(&Id::Common(IdCommon::Keybindings)).is_ok()); assert!(self.app.active(&Id::Common(IdCommon::Keybindings)).is_ok());
} }
/// ### umount_help
///
/// Umount help /// Umount help
pub(super) fn umount_help(&mut self) { pub(super) fn umount_help(&mut self) {
let _ = self.app.umount(&Id::Common(IdCommon::Keybindings)); let _ = self.app.umount(&Id::Common(IdCommon::Keybindings));
@@ -180,8 +162,6 @@ impl SetupActivity {
} }
} }
/// ### new_app
///
/// Clean app up and remount common components and global listener /// Clean app up and remount common components and global listener
fn new_app(&mut self, layout: ViewLayout) { fn new_app(&mut self, layout: ViewLayout) {
self.app.umount_all(); self.app.umount_all();
@@ -189,8 +169,6 @@ impl SetupActivity {
self.mount_commons(layout); self.mount_commons(layout);
} }
/// ### mount_commons
///
/// Mount common components /// Mount common components
fn mount_commons(&mut self, layout: ViewLayout) { fn mount_commons(&mut self, layout: ViewLayout) {
// Radio tab // Radio tab
@@ -213,8 +191,6 @@ impl SetupActivity {
.is_ok()); .is_ok());
} }
/// ### mount_global_listener
///
/// Mount global listener /// Mount global listener
fn mount_global_listener(&mut self) { fn mount_global_listener(&mut self) {
assert!(self assert!(self
@@ -263,8 +239,6 @@ impl SetupActivity {
.is_ok()); .is_ok());
} }
/// ### no_popup_mounted_clause
///
/// Returns a sub clause which requires that no popup is mounted in order to be satisfied /// Returns a sub clause which requires that no popup is mounted in order to be satisfied
fn no_popup_mounted_clause() -> SubClause<Id> { fn no_popup_mounted_clause() -> SubClause<Id> {
SubClause::And( SubClause::And(

View File

@@ -40,8 +40,6 @@ use tuirealm::{State, StateValue};
impl SetupActivity { impl SetupActivity {
// -- view // -- view
/// ### init_setup
///
/// Initialize setup view /// Initialize setup view
pub(super) fn init_setup(&mut self) { pub(super) fn init_setup(&mut self) {
// Init view (and mount commons) // Init view (and mount commons)
@@ -153,8 +151,6 @@ impl SetupActivity {
self.context = Some(ctx); self.context = Some(ctx);
} }
/// ### load_input_values
///
/// Load values from configuration into input fields /// Load values from configuration into input fields
pub(crate) fn load_input_values(&mut self) { pub(crate) fn load_input_values(&mut self) {
// Text editor // Text editor
@@ -267,8 +263,6 @@ impl SetupActivity {
.is_ok()); .is_ok());
} }
/// ### collect_input_values
///
/// Collect values from input and put them into the configuration /// Collect values from input and put them into the configuration
pub(crate) fn collect_input_values(&mut self) { pub(crate) fn collect_input_values(&mut self) {
if let Ok(State::One(StateValue::String(editor))) = if let Ok(State::One(StateValue::String(editor))) =

View File

@@ -37,8 +37,6 @@ use tuirealm::tui::widgets::Clear;
impl SetupActivity { impl SetupActivity {
// -- view // -- view
/// ### init_ssh_keys
///
/// Initialize ssh keys view /// Initialize ssh keys view
pub(super) fn init_ssh_keys(&mut self) { pub(super) fn init_ssh_keys(&mut self) {
// Init view (and mount commons) // Init view (and mount commons)
@@ -99,8 +97,6 @@ impl SetupActivity {
// -- mount // -- mount
/// ### mount_del_ssh_key
///
/// Mount delete ssh key component /// Mount delete ssh key component
pub(crate) fn mount_del_ssh_key(&mut self) { pub(crate) fn mount_del_ssh_key(&mut self) {
assert!(self assert!(self
@@ -114,15 +110,11 @@ impl SetupActivity {
assert!(self.app.active(&Id::Ssh(IdSsh::DelSshKeyPopup)).is_ok()); assert!(self.app.active(&Id::Ssh(IdSsh::DelSshKeyPopup)).is_ok());
} }
/// ### umount_del_ssh_key
///
/// Umount delete ssh key /// Umount delete ssh key
pub(crate) fn umount_del_ssh_key(&mut self) { pub(crate) fn umount_del_ssh_key(&mut self) {
let _ = self.app.umount(&Id::Ssh(IdSsh::DelSshKeyPopup)); let _ = self.app.umount(&Id::Ssh(IdSsh::DelSshKeyPopup));
} }
/// ### mount_new_ssh_key
///
/// Mount new ssh key prompt /// Mount new ssh key prompt
pub(crate) fn mount_new_ssh_key(&mut self) { pub(crate) fn mount_new_ssh_key(&mut self) {
assert!(self assert!(self
@@ -144,16 +136,12 @@ impl SetupActivity {
assert!(self.app.active(&Id::Ssh(IdSsh::SshHost)).is_ok()); assert!(self.app.active(&Id::Ssh(IdSsh::SshHost)).is_ok());
} }
/// ### umount_new_ssh_key
///
/// Umount new ssh key prompt /// Umount new ssh key prompt
pub(crate) fn umount_new_ssh_key(&mut self) { pub(crate) fn umount_new_ssh_key(&mut self) {
let _ = self.app.umount(&Id::Ssh(IdSsh::SshUsername)); let _ = self.app.umount(&Id::Ssh(IdSsh::SshUsername));
let _ = self.app.umount(&Id::Ssh(IdSsh::SshHost)); let _ = self.app.umount(&Id::Ssh(IdSsh::SshHost));
} }
/// ### reload_ssh_keys
///
/// Reload ssh keys /// Reload ssh keys
pub(crate) fn reload_ssh_keys(&mut self) { pub(crate) fn reload_ssh_keys(&mut self) {
let keys: Vec<String> = self let keys: Vec<String> = self

View File

@@ -35,8 +35,6 @@ use tuirealm::tui::layout::{Constraint, Direction, Layout};
impl SetupActivity { impl SetupActivity {
// -- view // -- view
/// ### init_theme
///
/// Initialize thene view /// Initialize thene view
pub(super) fn init_theme(&mut self) { pub(super) fn init_theme(&mut self) {
// Init view (and mount commons) // Init view (and mount commons)
@@ -298,8 +296,6 @@ impl SetupActivity {
.is_ok()); .is_ok());
} }
/// ### load_styles
///
/// Load values from theme into input fields /// Load values from theme into input fields
pub(crate) fn load_styles(&mut self) { pub(crate) fn load_styles(&mut self) {
let theme: Theme = self.theme().clone(); let theme: Theme = self.theme().clone();

View File

@@ -33,8 +33,6 @@ use crate::system::theme_provider::ThemeProvider;
use tuirealm::terminal::TerminalBridge; use tuirealm::terminal::TerminalBridge;
/// ## Context
///
/// Context holds data structures shared by the activities /// Context holds data structures shared by the activities
pub struct Context { pub struct Context {
ft_params: Option<FileTransferParams>, ft_params: Option<FileTransferParams>,
@@ -46,8 +44,6 @@ pub struct Context {
} }
impl Context { impl Context {
/// ### new
///
/// Instantiates a new Context /// Instantiates a new Context
pub fn new( pub fn new(
config_client: ConfigClient, config_client: ConfigClient,
@@ -106,15 +102,11 @@ impl Context {
// -- error // -- error
/// ### set_error
///
/// Set context error /// Set context error
pub fn set_error(&mut self, err: String) { pub fn set_error(&mut self, err: String) {
self.error = Some(err); self.error = Some(err);
} }
/// ### error
///
/// Get error message and remove it from the context /// Get error message and remove it from the context
pub fn error(&mut self) -> Option<String> { pub fn error(&mut self) -> Option<String> {
self.error.take() self.error.take()

View File

@@ -31,8 +31,6 @@ use std::collections::HashMap;
// -- store state // -- store state
/// ## StoreState
///
/// Store state describes a value in the store /// Store state describes a value in the store
#[allow(dead_code)] #[allow(dead_code)]
enum StoreState { enum StoreState {
@@ -46,8 +44,6 @@ enum StoreState {
// -- store // -- store
/// ## Store
///
/// Store represent the context store /// Store represent the context store
/// The store is a key-value hash map. Each key must be unique /// The store is a key-value hash map. Each key must be unique
/// To each key a `StoreState` is assigned /// To each key a `StoreState` is assigned
@@ -57,8 +53,6 @@ pub(crate) struct Store {
#[allow(dead_code)] #[allow(dead_code)]
impl Store { impl Store {
/// ### init
///
/// Initialize a new Store /// Initialize a new Store
pub fn init() -> Self { pub fn init() -> Self {
Store { Store {
@@ -68,8 +62,6 @@ impl Store {
// -- getters // -- getters
/// ### get_string
///
/// Get string from store /// Get string from store
pub fn get_string(&self, key: &str) -> Option<&str> { pub fn get_string(&self, key: &str) -> Option<&str> {
match self.store.get(key) { match self.store.get(key) {
@@ -78,8 +70,6 @@ impl Store {
} }
} }
/// ### get_signed
///
/// Get signed from store /// Get signed from store
pub fn get_signed(&self, key: &str) -> Option<isize> { pub fn get_signed(&self, key: &str) -> Option<isize> {
match self.store.get(key) { match self.store.get(key) {
@@ -88,8 +78,6 @@ impl Store {
} }
} }
/// ### get_unsigned
///
/// Get unsigned from store /// Get unsigned from store
pub fn get_unsigned(&self, key: &str) -> Option<usize> { pub fn get_unsigned(&self, key: &str) -> Option<usize> {
match self.store.get(key) { match self.store.get(key) {
@@ -98,8 +86,6 @@ impl Store {
} }
} }
/// ### get_float
///
/// get float from store /// get float from store
pub fn get_float(&self, key: &str) -> Option<f64> { pub fn get_float(&self, key: &str) -> Option<f64> {
match self.store.get(key) { match self.store.get(key) {
@@ -108,8 +94,6 @@ impl Store {
} }
} }
/// ### get_boolean
///
/// get boolean from store /// get boolean from store
pub fn get_boolean(&self, key: &str) -> Option<bool> { pub fn get_boolean(&self, key: &str) -> Option<bool> {
match self.store.get(key) { match self.store.get(key) {
@@ -118,8 +102,6 @@ impl Store {
} }
} }
/// ### isset
///
/// Check if a state is set in the store /// Check if a state is set in the store
pub fn isset(&self, key: &str) -> bool { pub fn isset(&self, key: &str) -> bool {
self.store.get(key).is_some() self.store.get(key).is_some()
@@ -127,44 +109,32 @@ impl Store {
// -- setters // -- setters
/// ### set_string
///
/// Set string into the store /// Set string into the store
pub fn set_string(&mut self, key: &str, val: String) { pub fn set_string(&mut self, key: &str, val: String) {
self.store.insert(key.to_string(), StoreState::Str(val)); self.store.insert(key.to_string(), StoreState::Str(val));
} }
/// ### set_signed
///
/// Set signed number /// Set signed number
pub fn set_signed(&mut self, key: &str, val: isize) { pub fn set_signed(&mut self, key: &str, val: isize) {
self.store.insert(key.to_string(), StoreState::Signed(val)); self.store.insert(key.to_string(), StoreState::Signed(val));
} }
/// ### set_signed
///
/// Set unsigned number /// Set unsigned number
pub fn set_unsigned(&mut self, key: &str, val: usize) { pub fn set_unsigned(&mut self, key: &str, val: usize) {
self.store self.store
.insert(key.to_string(), StoreState::Unsigned(val)); .insert(key.to_string(), StoreState::Unsigned(val));
} }
/// ### set_float
///
/// Set floating point number /// Set floating point number
pub fn set_float(&mut self, key: &str, val: f64) { pub fn set_float(&mut self, key: &str, val: f64) {
self.store.insert(key.to_string(), StoreState::Float(val)); self.store.insert(key.to_string(), StoreState::Float(val));
} }
/// ### set_boolean
///
/// Set boolean /// Set boolean
pub fn set_boolean(&mut self, key: &str, val: bool) { pub fn set_boolean(&mut self, key: &str, val: bool) {
self.store.insert(key.to_string(), StoreState::Boolean(val)); self.store.insert(key.to_string(), StoreState::Boolean(val));
} }
/// ### set
///
/// Set a key as a flag; has no value /// Set a key as a flag; has no value
pub fn set(&mut self, key: &str) { pub fn set(&mut self, key: &str) {
self.store.insert(key.to_string(), StoreState::Flag); self.store.insert(key.to_string(), StoreState::Flag);
@@ -172,8 +142,6 @@ impl Store {
// -- Consumers // -- Consumers
/// ### take_string
///
/// Take string from store /// Take string from store
pub fn take_string(&mut self, key: &str) -> Option<String> { pub fn take_string(&mut self, key: &str) -> Option<String> {
match self.store.remove(key) { match self.store.remove(key) {
@@ -182,8 +150,6 @@ impl Store {
} }
} }
/// ### take_signed
///
/// Take signed from store /// Take signed from store
pub fn take_signed(&mut self, key: &str) -> Option<isize> { pub fn take_signed(&mut self, key: &str) -> Option<isize> {
match self.store.remove(key) { match self.store.remove(key) {
@@ -192,8 +158,6 @@ impl Store {
} }
} }
/// ### take_unsigned
///
/// Take unsigned from store /// Take unsigned from store
pub fn take_unsigned(&mut self, key: &str) -> Option<usize> { pub fn take_unsigned(&mut self, key: &str) -> Option<usize> {
match self.store.remove(key) { match self.store.remove(key) {
@@ -202,8 +166,6 @@ impl Store {
} }
} }
/// ### get_float
///
/// Take float from store /// Take float from store
pub fn take_float(&mut self, key: &str) -> Option<f64> { pub fn take_float(&mut self, key: &str) -> Option<f64> {
match self.store.remove(key) { match self.store.remove(key) {
@@ -212,8 +174,6 @@ impl Store {
} }
} }
/// ### get_boolean
///
/// Take boolean from store /// Take boolean from store
pub fn take_boolean(&mut self, key: &str) -> Option<bool> { pub fn take_boolean(&mut self, key: &str) -> Option<bool> {
match self.store.remove(key) { match self.store.remove(key) {

View File

@@ -28,8 +28,6 @@
// Ext // Ext
use rand::{distributions::Alphanumeric, thread_rng, Rng}; use rand::{distributions::Alphanumeric, thread_rng, Rng};
/// ## random_alphanumeric_with_len
///
/// Generate a random alphanumeric string with provided length /// Generate a random alphanumeric string with provided length
pub fn random_alphanumeric_with_len(len: usize) -> String { pub fn random_alphanumeric_with_len(len: usize) -> String {
let mut rng = thread_rng(); let mut rng = thread_rng();