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
impl Node
Sourcepub async fn connect(
config: NodeConfig,
players: PlayerManager,
) -> Result<(Self, IncomingEvents), NodeError>
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.
Sourcepub const fn config(&self) -> &NodeConfig
pub const fn config(&self) -> &NodeConfig
Retrieve an immutable reference to the node’s configuration.
Sourcepub const fn players(&self) -> &PlayerManager
pub const fn players(&self) -> &PlayerManager
Retrieve an immutable reference to the player manager used by the node.
Sourcepub fn send(&self, event: OutgoingEvent) -> Result<(), NodeSenderError>
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.
Sourcepub fn sender(&self) -> NodeSender
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.