pub struct Manager { /* private fields */ }Expand description
Controls the creation and deleting of servers, and whether they are currently active.
Implementations§
Source§impl Manager
impl Manager
Sourcepub fn new(
server_files_folder: &str,
version_folder: &str,
jar_name: &str,
) -> Manager
pub fn new( server_files_folder: &str, version_folder: &str, jar_name: &str, ) -> Manager
Creates a new server manager
§Arguments
server_files_folder- the folder that will hold each server’s folder, which contains its server files.version_folder- the folder containing the base files of servers for the MC versions that you wish to host. Used as a base to create new servers.
§Examples
let manager = serbo::Manager::new("folder1","folder2");§Remarks
The version_folder should be a folder that contains folders that are named the same as the MC server files they contain.
Sourcepub fn create(&mut self, id: &str, version: &str) -> Result<(), Error>
pub fn create(&mut self, id: &str, version: &str) -> Result<(), Error>
Creates a new MC server folder under the server_files_folder
§Arguments
id- The id for the serverversion- The target version for the server.jar_name- The name of the jar file that should be executed to start the server.
§Examples
let manager = serbo::Manager::new("folder1","folder2");
manager.create("1","1.16.1");§Remarks
Returns a result that contains the id that was assigned to the server
Sourcepub fn get(&mut self, id: &str) -> Option<&mut Instance>
pub fn get(&mut self, id: &str) -> Option<&mut Instance>
Returns an Option
§Arguments
id- The id that represents the requested server
§Examples
let manager = serbo::Manager::new("folder1","folder2");
//Returns an Option
let instance:serbo::Instance = manager.get("1").unwrap();§Remarks
Queries the currently online servers, for get to return, must have been launched by calling start
Sourcepub fn exists(&mut self, id: &str) -> bool
pub fn exists(&mut self, id: &str) -> bool
Checks if server files exist for a given id
§Arguments
id- The id that represents the requested server
Sourcepub fn start(&mut self, id: &str, port: u32) -> Result<u32, Error>
pub fn start(&mut self, id: &str, port: u32) -> Result<u32, Error>
Launches a server
§Arguments
id- The id that represents the requested serverport- The port that the server should be started on
Auto Trait Implementations§
impl Freeze for Manager
impl !RefUnwindSafe for Manager
impl Send for Manager
impl Sync for Manager
impl Unpin for Manager
impl !UnwindSafe for Manager
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