Struct Manager

Source
pub struct Manager { /* private fields */ }
Expand description

Controls the creation and deleting of servers, and whether they are currently active.

Implementations§

Source§

impl Manager

Source

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.

Source

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 server
  • version - 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

Source

pub fn get(&mut self, id: &str) -> Option<&mut Instance>

Returns an Option containing a Instance that represents the currently online server represented by the provided id

§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

Source

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
Source

pub fn is_online(&mut self, id: &str) -> bool

Checks if the server is online

§Arguments
  • id - The id that represents the requested server
§Remarks

Queries the currently online servers, must have been launched by calling start

Source

pub fn start(&mut self, id: &str, port: u32) -> Result<u32, Error>

Launches a server

§Arguments
  • id - The id that represents the requested server
  • port - The port that the server should be started on
Source

pub fn stop(&mut self, id: &str) -> Result<(), Error>

Stops a server

§Arguments
  • id - The id that represents the requested server
Source

pub fn delete(&mut self, id: &str) -> Result<(), Error>

Deletes a server’s files

§Arguments
  • id - The id that represents the requested server
§Remarks

Stops the server if it’s currently running

Source

pub fn change_version(&mut self, id: &str, target: &str) -> Result<(), Error>

Changes a server’s version

§Arguments
  • id - The id that represents the requested server
  • target - The target version to be switched to
§Remarks

Stops the server if it’s currently running

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.