mirror of
https://github.com/sayanarijit/xplr
synced 2024-11-14 18:12:54 +00:00
32 lines
703 B
Rust
32 lines
703 B
Rust
use crate::node::Node;
|
|
use chrono::{DateTime, Utc};
|
|
use serde::{Deserialize, Serialize};
|
|
|
|
#[derive(Debug, Clone, Eq, PartialEq, Serialize, Deserialize)]
|
|
pub struct DirectoryBuffer {
|
|
pub parent: String,
|
|
pub nodes: Vec<Node>,
|
|
pub total: usize,
|
|
pub focus: usize,
|
|
|
|
#[serde(skip)]
|
|
pub explored_at: DateTime<Utc>,
|
|
}
|
|
|
|
impl DirectoryBuffer {
|
|
pub fn new(parent: String, nodes: Vec<Node>, focus: usize) -> Self {
|
|
let total = nodes.len();
|
|
Self {
|
|
parent,
|
|
nodes,
|
|
total,
|
|
focus,
|
|
explored_at: Utc::now(),
|
|
}
|
|
}
|
|
|
|
pub fn focused_node(&self) -> Option<&Node> {
|
|
self.nodes.get(self.focus)
|
|
}
|
|
}
|