pub struct StdSystem<C: CustomTypes<StdSystem<C>>> { /* private fields */ }
Expand description

A type implementing the System trait which supports all features.

Implementations§

source§

impl<C: CustomTypes<StdSystem<C>>> StdSystem<C>

source

pub fn new( base_url: String, project_name: Option<&str>, config: Config<C, Self> ) -> Self

Initializes a new instance of StdSystem targeting the given NetsBlox server base url (e.g., https://editor.netsblox.org).

source

pub async fn call_rpc_async( &self, service: &str, rpc: &str, args: &[(&str, &Json)] ) -> Result<C::Intermediate, String>

Asynchronously calls an RPC and returns the result. This function directly makes requests to NetsBlox, bypassing any RPC hook defined by Config.

source

pub fn get_public_id(&self) -> String

Gets the public id of the running system that can be used to send messages to this client.

Trait Implementations§

source§

impl<C: CustomTypes<StdSystem<C>>> System<C> for StdSystem<C>

§

type RequestKey = RequestKey<C>

Key type used to await the result of an asynchronous request.
§

type CommandKey = CommandKey

Key type used to await the completion of an asynchronous command.
§

type ExternReplyKey = ExternReplyKey

Key type used to await the result of a “send message and wait” block (response from target).
§

type InternReplyKey = InternReplyKey

Key type used to reply to a message that was sent to this client with the expectation of receiving a response. This type is required to be Clone because there can be multiple message handlers for the same message type.
source§

fn rand<T, R>(&self, range: R) -> Result<T, ErrorCause<C, StdSystem<C>>>where T: SampleUniform, R: SampleRange<T>,

Gets a random value sampled from the given range, which is assumed to be non-empty. The input for this generic function is such that it is compatible with rand::Rng::gen_range, which makes it possible to implement this function with any random provider under the rand crate standard.
source§

fn time_ms(&self) -> Result<u64, ErrorCause<C, StdSystem<C>>>

Gets the current time in milliseconds. This is not required to represent the actual real-world time; e.g., this could simply measure uptime. Subsequent values are required to be non-decreasing.
source§

fn perform_request<'gc>( &self, mc: &Mutation<'gc>, request: Request<'gc, C, Self>, entity: &mut Entity<'gc, C, Self> ) -> Result<MaybeAsync<Result<Value<'gc, C, Self>, String>, Self::RequestKey>, ErrorCause<C, Self>>

Performs a general request which returns a value to the system. Ideally, this function should be non-blocking, and the requestor will await the result asynchronously. The Entity that made the request is provided for context.
source§

fn poll_request<'gc>( &self, mc: &Mutation<'gc>, key: &Self::RequestKey, _: &mut Entity<'gc, C, Self> ) -> Result<AsyncResult<Result<Value<'gc, C, Self>, String>>, ErrorCause<C, Self>>

Poll for the completion of an asynchronous request. The Entity that made the request is provided for context.
source§

fn perform_command<'gc, 'a>( &self, mc: &Mutation<'gc>, command: Command<'gc, 'a, C, Self>, entity: &mut Entity<'gc, C, Self> ) -> Result<MaybeAsync<Result<(), String>, Self::CommandKey>, ErrorCause<C, Self>>

Performs a general command which does not return a value to the system. Ideally, this function should be non-blocking, and the commander will await the task’s completion asynchronously. The Entity that issued the command is provided for context.
source§

fn poll_command<'gc>( &self, _: &Mutation<'gc>, key: &Self::CommandKey, _: &mut Entity<'gc, C, Self> ) -> Result<AsyncResult<Result<(), String>>, ErrorCause<C, Self>>

Poll for the completion of an asynchronous command. The Entity that issued the command is provided for context.
source§

fn send_message( &self, msg_type: String, values: Vec<(String, Json)>, targets: Vec<String>, expect_reply: bool ) -> Result<Option<Self::ExternReplyKey>, ErrorCause<C, StdSystem<C>>>

Sends a message containing a set of named values to each of the specified targets. The expect_reply value controls whether or not to use a reply mechanism to asynchronously receive a response from the target(s). In the case that there are multiple targets, only the first reply (if any) should be used.
source§

fn poll_reply(&self, key: &Self::ExternReplyKey) -> AsyncResult<Option<Json>>

Polls for a response from a client initiated by System::send_message. If the client responds, a value of [Some(x)] is returned. The system may elect to impose a timeout for reply results, in which case None is returned instead.
source§

fn send_reply( &self, key: Self::InternReplyKey, value: Json ) -> Result<(), ErrorCause<C, Self>>

Sends a reply to the sender of a blocking message this client received.
source§

fn receive_message(&self) -> Option<IncomingMessage<C, Self>>

Attempts to receive a message from the message buffer. This operation is always non-blocking and returns None if there are no messages in the buffer. If a message is received, a tuple of form (msg_type, values, reply_key) is returned.

Auto Trait Implementations§

§

impl<C> !RefUnwindSafe for StdSystem<C>

§

impl<C> !Send for StdSystem<C>

§

impl<C> !Sync for StdSystem<C>

§

impl<C> Unpin for StdSystem<C>

§

impl<C> !UnwindSafe for StdSystem<C>

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.

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, 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

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