pub struct Server {
pub is_server_running: Arc<Mutex<bool>>,
pub ip: IpAddr,
pub port: u16,
pub path: String,
pub buffer_size: u64,
pub stop_signal: Arc<Notify>,
}Expand description
Represents a file server that listens for incoming connections and handles file transfer requests.
Fields§
§is_server_running: Arc<Mutex<bool>>Indicates if the server is currently running.
ip: IpAddrThe IP address on which the server listens.
port: u16The port on which the server listens.
path: StringThe path to the directory where files are stored.
buffer_size: u64Buffer size for file transfer operations.
stop_signal: Arc<Notify>Notification signal for stopping the server.
Implementations§
Source§impl Server
impl Server
Sourcepub fn new(
ip: IpAddr,
port: u16,
path: &str,
buffer_size: u64,
stop_signal: Arc<Notify>,
) -> Self
pub fn new( ip: IpAddr, port: u16, path: &str, buffer_size: u64, stop_signal: Arc<Notify>, ) -> Self
Creates a new instance of the Server.
§Parameters
ip: IP address on which the server will listen.port: Port on which the server will listen.path: Directory path for file storage and retrieval.buffer_size: Size of the buffer used for file transfers.
Sourcepub async fn start_server(&mut self) -> Result<(), Box<dyn Error>>
pub async fn start_server(&mut self) -> Result<(), Box<dyn Error>>
Starts the server, accepting and handling incoming connections.
pub async fn stop_server(&self)
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Server
impl !RefUnwindSafe for Server
impl Send for Server
impl Sync for Server
impl Unpin for Server
impl !UnwindSafe for Server
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more