Struct twilight_lavalink::node::Node

source ·
pub struct Node { /* private fields */ }
Expand description

A connection to a single Lavalink server. It receives events and forwards events from players to the server.

Please refer to the module documentation.

Implementations§

source§

impl Node

source

pub async fn connect( config: NodeConfig, players: PlayerManager, ) -> Result<(Self, IncomingEvents), NodeError>

Connect to a node, providing a player manager so that the node can update player details.

Please refer to the module documentation for some additional information about directly creating and using nodes. You are encouraged to use the Lavalink client instead.

§Errors

Returns an error of type Connecting if the connection fails after several backoff attempts.

Returns an error of type BuildingConnectionRequest if the request failed to build.

Returns an error of type Unauthorized if the supplied authorization is rejected by the node.

source

pub const fn config(&self) -> &NodeConfig

Retrieve an immutable reference to the node’s configuration.

source

pub const fn players(&self) -> &PlayerManager

Retrieve an immutable reference to the player manager used by the node.

source

pub fn send(&self, event: OutgoingEvent) -> Result<(), NodeSenderError>

Retrieve an immutable reference to the node’s configuration.

Note that sending player events through the node’s sender won’t update player states, such as whether it’s paused.

§Errors

Returns a NodeSenderErrorType::Sending error type if node is no longer connected.

source

pub fn sender(&self) -> NodeSender

Retrieve a unique sender to send events to the Lavalink server.

Note that sending player events through the node’s sender won’t update player states, such as whether it’s paused.

source

pub async fn stats(&self) -> Stats

Retrieve a copy of the node’s stats.

source

pub async fn penalty(&self) -> i32

Retrieve the calculated penalty score of the node.

This score can be used to calculate how loaded the server is. A higher number means it is more heavily loaded.

Trait Implementations§

source§

impl Debug for Node

source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl Freeze for Node

§

impl !RefUnwindSafe for Node

§

impl Send for Node

§

impl Sync for Node

§

impl Unpin for Node

§

impl !UnwindSafe for Node

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.

§

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

§

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

§

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