Struct scl_core::client::Client

source ·
pub struct Client {
    pub cmd: Command,
    pub game_dir: String,
    pub java_path: String,
    pub args: Vec<String>,
    pub process: Option<Child>,
}
Expand description

一个客户端结构,通过 ClientConfig 提供的信息组合启动参数,运行游戏

Fields§

§cmd: Command

客户端的实际指令对象

§game_dir: String

当前游戏目录路径

§java_path: String

当前使用的 Java 运行时路径

§args: Vec<String>

当前启动参数的副本,包含 Java 自身

§process: Option<Child>

正在运行的进程对象

Implementations§

source§

impl Client

source

pub async fn new(cfg: ClientConfig) -> Result<Self>

根据传入的启动客户端版本设定创建一个客户端

这将会检查元数据,并组合出启动参数,之后可以使用 Client::launch 启动游戏

source

pub fn stdin(self, cfg: impl Into<Stdio>) -> Self

以 Builder 模式设置启动程序的标准输入方式

详情请参考 std::process::Command::stdin

source

pub fn stdout(self, cfg: impl Into<Stdio>) -> Self

以 Builder 模式设置启动程序的标准输出方式

详情请参考 std::process::Command::stdout

source

pub fn stderr(self, cfg: impl Into<Stdio>) -> Self

以 Builder 模式设置启动程序的标准错误输出方式

详情请参考 std::process::Command::stderr

source

pub fn set_stdin(&mut self, cfg: impl Into<Stdio>)

设置启动程序的标准输入方式

详情请参考 std::process::Command::stdin

source

pub fn set_stdout(&mut self, cfg: impl Into<Stdio>)

设置启动程序的标准输出方式

详情请参考 std::process::Command::stdout

source

pub fn set_stderr(&mut self, cfg: impl Into<Stdio>)

设置启动程序的标准错误输出方式

详情请参考 std::process::Command::stderr

source

pub fn get_args(&self) -> &[String]

获取参数引用,参数数组的第一个成员为提供的 Java 执行文件

注意参数可能包含用户的个人令牌等敏感信息,如需输出请自行确保信息安全

source

pub fn take_args(self) -> Vec<String>

拿出参数,参数数组的第一个成员为提供的 Java 执行文件

注意参数可能包含用户的个人令牌等敏感信息,如需输出请自行确保信息安全

source

pub fn take_cmd(self) -> Command

拿出 Command

source

pub async fn launch(&mut self) -> Result<u32>

启动游戏,并返回进程 ID

source

pub fn stop(&mut self) -> Result<()>

如果游戏进程还在运行,则尝试停止游戏进程

Trait Implementations§

source§

impl Display for Client

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl !RefUnwindSafe for Client

§

impl Send for Client

§

impl Sync for Client

§

impl Unpin for Client

§

impl !UnwindSafe for Client

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for Twhere 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> Same<T> for T

§

type Output = T

Should always be Self
source§

impl<T> ToString for Twhere T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
source§

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

§

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 Twhere U: TryFrom<T>,

§

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.
§

impl<V, T> VZip<V> for Twhere V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more
source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more