twilight_lavalink::node

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

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

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