mirror of
https://github.com/veeso/termscp.git
synced 2025-12-07 09:36:00 -08:00
Fixed warnings
This commit is contained in:
@@ -25,8 +25,6 @@
|
|||||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
* SOFTWARE.
|
* SOFTWARE.
|
||||||
*/
|
*/
|
||||||
use std::path::PathBuf;
|
|
||||||
|
|
||||||
// Deps
|
// Deps
|
||||||
use crate::filetransfer::FileTransferProtocol;
|
use crate::filetransfer::FileTransferProtocol;
|
||||||
use crate::host::{HostError, Localhost};
|
use crate::host::{HostError, Localhost};
|
||||||
@@ -39,6 +37,7 @@ use crate::ui::activities::{
|
|||||||
use crate::ui::context::{Context, FileTransferParams};
|
use crate::ui::context::{Context, FileTransferParams};
|
||||||
|
|
||||||
// Namespaces
|
// Namespaces
|
||||||
|
use std::path::{Path, PathBuf};
|
||||||
use std::thread::sleep;
|
use std::thread::sleep;
|
||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
|
|
||||||
@@ -63,9 +62,9 @@ impl ActivityManager {
|
|||||||
/// ### new
|
/// ### new
|
||||||
///
|
///
|
||||||
/// Initializes a new Activity Manager
|
/// Initializes a new Activity Manager
|
||||||
pub fn new(local_dir: &PathBuf, interval: Duration) -> Result<ActivityManager, HostError> {
|
pub fn new(local_dir: &Path, interval: Duration) -> Result<ActivityManager, HostError> {
|
||||||
// Prepare Context
|
// Prepare Context
|
||||||
let host: Localhost = match Localhost::new(local_dir.clone()) {
|
let host: Localhost = match Localhost::new(local_dir.to_path_buf()) {
|
||||||
Ok(h) => h,
|
Ok(h) => h,
|
||||||
Err(e) => return Err(e),
|
Err(e) => return Err(e),
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -43,8 +43,6 @@ impl FileTransferActivity {
|
|||||||
}
|
}
|
||||||
// Eventually push front the new record
|
// Eventually push front the new record
|
||||||
self.log_records.push_front(record);
|
self.log_records.push_front(record);
|
||||||
// Set log index
|
|
||||||
self.log_index = 0;
|
|
||||||
// Update log
|
// Update log
|
||||||
let msg = self.update_logbox();
|
let msg = self.update_logbox();
|
||||||
self.update(msg);
|
self.update(msg);
|
||||||
|
|||||||
@@ -214,7 +214,6 @@ pub struct FileTransferActivity {
|
|||||||
remote: FileExplorer, // Remote File explorer state
|
remote: FileExplorer, // Remote File explorer state
|
||||||
found: Option<FileExplorer>, // File explorer for find result
|
found: Option<FileExplorer>, // File explorer for find result
|
||||||
tab: FileExplorerTab, // Current selected tab
|
tab: FileExplorerTab, // Current selected tab
|
||||||
log_index: usize, // Current log index entry selected
|
|
||||||
log_records: VecDeque<LogRecord>, // Log records
|
log_records: VecDeque<LogRecord>, // Log records
|
||||||
log_size: usize, // Log records size (max)
|
log_size: usize, // Log records size (max)
|
||||||
transfer: TransferStates, // Transfer states
|
transfer: TransferStates, // Transfer states
|
||||||
@@ -244,7 +243,6 @@ impl FileTransferActivity {
|
|||||||
remote: Self::build_explorer(config_client.as_ref()),
|
remote: Self::build_explorer(config_client.as_ref()),
|
||||||
found: None,
|
found: None,
|
||||||
tab: FileExplorerTab::Local,
|
tab: FileExplorerTab::Local,
|
||||||
log_index: 0,
|
|
||||||
log_records: VecDeque::with_capacity(256), // 256 events is enough I guess
|
log_records: VecDeque::with_capacity(256), // 256 events is enough I guess
|
||||||
log_size: 256, // Must match with capacity
|
log_size: 256, // Must match with capacity
|
||||||
transfer: TransferStates::default(),
|
transfer: TransferStates::default(),
|
||||||
|
|||||||
@@ -38,23 +38,10 @@ use tui::{
|
|||||||
widgets::{Block, BorderType, List, ListItem},
|
widgets::{Block, BorderType, List, ListItem},
|
||||||
};
|
};
|
||||||
|
|
||||||
// -- state
|
|
||||||
|
|
||||||
struct OwnStates {
|
|
||||||
focus: bool,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Default for OwnStates {
|
|
||||||
fn default() -> Self {
|
|
||||||
Self { focus: false }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// -- component
|
// -- component
|
||||||
|
|
||||||
pub struct MsgBox {
|
pub struct MsgBox {
|
||||||
props: Props,
|
props: Props,
|
||||||
states: OwnStates,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl MsgBox {
|
impl MsgBox {
|
||||||
@@ -62,10 +49,7 @@ impl MsgBox {
|
|||||||
///
|
///
|
||||||
/// Instantiate a new Text component
|
/// Instantiate a new Text component
|
||||||
pub fn new(props: Props) -> Self {
|
pub fn new(props: Props) -> Self {
|
||||||
MsgBox {
|
MsgBox { props }
|
||||||
props,
|
|
||||||
states: OwnStates::default(),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -179,16 +163,12 @@ impl Component for MsgBox {
|
|||||||
/// ### blur
|
/// ### blur
|
||||||
///
|
///
|
||||||
/// Blur component
|
/// Blur component
|
||||||
fn blur(&mut self) {
|
fn blur(&mut self) {}
|
||||||
self.states.focus = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// ### active
|
/// ### active
|
||||||
///
|
///
|
||||||
/// Active component
|
/// Active component
|
||||||
fn active(&mut self) {
|
fn active(&mut self) {}
|
||||||
self.states.focus = true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
@@ -217,12 +197,6 @@ mod tests {
|
|||||||
))
|
))
|
||||||
.build(),
|
.build(),
|
||||||
);
|
);
|
||||||
// Focus
|
|
||||||
assert_eq!(component.states.focus, false);
|
|
||||||
component.active();
|
|
||||||
assert_eq!(component.states.focus, true);
|
|
||||||
component.blur();
|
|
||||||
assert_eq!(component.states.focus, false);
|
|
||||||
// Get value
|
// Get value
|
||||||
assert_eq!(component.get_value(), Payload::None);
|
assert_eq!(component.get_value(), Payload::None);
|
||||||
// Event
|
// Event
|
||||||
|
|||||||
@@ -34,23 +34,10 @@ use tui::{
|
|||||||
widgets::{Block, Gauge},
|
widgets::{Block, Gauge},
|
||||||
};
|
};
|
||||||
|
|
||||||
// -- state
|
|
||||||
|
|
||||||
struct OwnStates {
|
|
||||||
focus: bool,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Default for OwnStates {
|
|
||||||
fn default() -> Self {
|
|
||||||
OwnStates { focus: false }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// -- component
|
// -- component
|
||||||
|
|
||||||
pub struct ProgressBar {
|
pub struct ProgressBar {
|
||||||
props: Props,
|
props: Props,
|
||||||
states: OwnStates,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ProgressBar {
|
impl ProgressBar {
|
||||||
@@ -58,10 +45,7 @@ impl ProgressBar {
|
|||||||
///
|
///
|
||||||
/// Instantiate a new Progress Bar
|
/// Instantiate a new Progress Bar
|
||||||
pub fn new(props: Props) -> Self {
|
pub fn new(props: Props) -> Self {
|
||||||
ProgressBar {
|
ProgressBar { props }
|
||||||
props,
|
|
||||||
states: OwnStates::default(),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -156,16 +140,12 @@ impl Component for ProgressBar {
|
|||||||
/// ### blur
|
/// ### blur
|
||||||
///
|
///
|
||||||
/// Blur component
|
/// Blur component
|
||||||
fn blur(&mut self) {
|
fn blur(&mut self) {}
|
||||||
self.states.focus = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// ### active
|
/// ### active
|
||||||
///
|
///
|
||||||
/// Active component
|
/// Active component
|
||||||
fn active(&mut self) {
|
fn active(&mut self) {}
|
||||||
self.states.focus = true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
@@ -186,12 +166,6 @@ mod tests {
|
|||||||
))
|
))
|
||||||
.build(),
|
.build(),
|
||||||
);
|
);
|
||||||
// Focus
|
|
||||||
assert_eq!(component.states.focus, false);
|
|
||||||
component.active();
|
|
||||||
assert_eq!(component.states.focus, true);
|
|
||||||
component.blur();
|
|
||||||
assert_eq!(component.states.focus, false);
|
|
||||||
// Get value
|
// Get value
|
||||||
assert_eq!(component.get_value(), Payload::None);
|
assert_eq!(component.get_value(), Payload::None);
|
||||||
// Event
|
// Event
|
||||||
|
|||||||
@@ -35,18 +35,6 @@ use tui::{
|
|||||||
widgets::{Block, BorderType, List, ListItem},
|
widgets::{Block, BorderType, List, ListItem},
|
||||||
};
|
};
|
||||||
|
|
||||||
// -- state
|
|
||||||
|
|
||||||
struct OwnStates {
|
|
||||||
focus: bool,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Default for OwnStates {
|
|
||||||
fn default() -> Self {
|
|
||||||
OwnStates { focus: false }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// -- component
|
// -- component
|
||||||
|
|
||||||
/// ## Table
|
/// ## Table
|
||||||
@@ -54,7 +42,6 @@ impl Default for OwnStates {
|
|||||||
/// Table is a table component. List n rows with n text span columns
|
/// Table is a table component. List n rows with n text span columns
|
||||||
pub struct Table {
|
pub struct Table {
|
||||||
props: Props,
|
props: Props,
|
||||||
states: OwnStates,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Table {
|
impl Table {
|
||||||
@@ -62,10 +49,7 @@ impl Table {
|
|||||||
///
|
///
|
||||||
/// Instantiate a new Table component
|
/// Instantiate a new Table component
|
||||||
pub fn new(props: Props) -> Self {
|
pub fn new(props: Props) -> Self {
|
||||||
Table {
|
Table { props }
|
||||||
props,
|
|
||||||
states: OwnStates::default(),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -168,16 +152,12 @@ impl Component for Table {
|
|||||||
/// ### blur
|
/// ### blur
|
||||||
///
|
///
|
||||||
/// Blur component
|
/// Blur component
|
||||||
fn blur(&mut self) {
|
fn blur(&mut self) {}
|
||||||
self.states.focus = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// ### active
|
/// ### active
|
||||||
///
|
///
|
||||||
/// Active component
|
/// Active component
|
||||||
fn active(&mut self) {
|
fn active(&mut self) {}
|
||||||
self.states.focus = true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
@@ -204,12 +184,6 @@ mod tests {
|
|||||||
))
|
))
|
||||||
.build(),
|
.build(),
|
||||||
);
|
);
|
||||||
// Focus
|
|
||||||
assert_eq!(component.states.focus, false);
|
|
||||||
component.active();
|
|
||||||
assert_eq!(component.states.focus, true);
|
|
||||||
component.blur();
|
|
||||||
assert_eq!(component.states.focus, false);
|
|
||||||
// Get value
|
// Get value
|
||||||
assert_eq!(component.get_value(), Payload::None);
|
assert_eq!(component.get_value(), Payload::None);
|
||||||
// Event
|
// Event
|
||||||
|
|||||||
@@ -30,23 +30,10 @@ use super::{Canvas, Component, InputEvent, Msg, Payload, Props, PropsBuilder};
|
|||||||
// ext
|
// ext
|
||||||
use tui::{layout::Rect, style::Style, widgets::Paragraph};
|
use tui::{layout::Rect, style::Style, widgets::Paragraph};
|
||||||
|
|
||||||
// -- state
|
|
||||||
|
|
||||||
struct OwnStates {
|
|
||||||
focus: bool,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Default for OwnStates {
|
|
||||||
fn default() -> Self {
|
|
||||||
OwnStates { focus: false }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// -- component
|
// -- component
|
||||||
|
|
||||||
pub struct Title {
|
pub struct Title {
|
||||||
props: Props,
|
props: Props,
|
||||||
states: OwnStates,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Title {
|
impl Title {
|
||||||
@@ -54,10 +41,7 @@ impl Title {
|
|||||||
///
|
///
|
||||||
/// Instantiate a new Title component
|
/// Instantiate a new Title component
|
||||||
pub fn new(props: Props) -> Self {
|
pub fn new(props: Props) -> Self {
|
||||||
Title {
|
Title { props }
|
||||||
props,
|
|
||||||
states: OwnStates::default(),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -134,16 +118,12 @@ impl Component for Title {
|
|||||||
/// ### blur
|
/// ### blur
|
||||||
///
|
///
|
||||||
/// Blur component
|
/// Blur component
|
||||||
fn blur(&mut self) {
|
fn blur(&mut self) {}
|
||||||
self.states.focus = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// ### active
|
/// ### active
|
||||||
///
|
///
|
||||||
/// Active component
|
/// Active component
|
||||||
fn active(&mut self) {
|
fn active(&mut self) {}
|
||||||
self.states.focus = true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
@@ -161,12 +141,6 @@ mod tests {
|
|||||||
.with_texts(TextParts::new(Some(String::from("Title")), None))
|
.with_texts(TextParts::new(Some(String::from("Title")), None))
|
||||||
.build(),
|
.build(),
|
||||||
);
|
);
|
||||||
// Focus
|
|
||||||
assert_eq!(component.states.focus, false);
|
|
||||||
component.active();
|
|
||||||
assert_eq!(component.states.focus, true);
|
|
||||||
component.blur();
|
|
||||||
assert_eq!(component.states.focus, false);
|
|
||||||
// Get value
|
// Get value
|
||||||
assert_eq!(component.get_value(), Payload::None);
|
assert_eq!(component.get_value(), Payload::None);
|
||||||
// Event
|
// Event
|
||||||
|
|||||||
Reference in New Issue
Block a user