pub struct RocketClient { /* private fields */ }
Expand description
The RocketClient
type. This contains the connected socket and other fields.
Implementations§
Source§impl RocketClient
impl RocketClient
Sourcepub fn new() -> Result<Self, Error>
pub fn new() -> Result<Self, Error>
Construct a new RocketClient.
This constructs a new Rocket client and connects to localhost on port 1338.
§Errors
Error::Connect
if connection cannot be established, or Error::Handshake
if the handshake fails.
§Examples
let mut rocket = RocketClient::new().unwrap();
Sourcepub fn connect(addr: impl ToSocketAddrs) -> Result<Self, Error>
pub fn connect(addr: impl ToSocketAddrs) -> Result<Self, Error>
Construct a new RocketClient.
This constructs a new Rocket client and connects to a specified host and port.
§Errors
Error::Connect
if connection cannot be established, or Error::Handshake
if the handshake fails.
§Examples
let mut rocket = RocketClient::connect(("localhost", 1338)).unwrap();
Sourcepub fn get_track_mut(&mut self, name: &str) -> Result<&mut Track, Error>
pub fn get_track_mut(&mut self, name: &str) -> Result<&mut Track, Error>
Get track by name.
If the track does not yet exist it will be created.
§Errors
This method can return an Error::IOError
if Rocket tracker disconnects.
§Panics
Will panic if name
’s length exceeds u32::MAX
.
§Examples
let track = rocket.get_track_mut("namespace:track").unwrap();
track.get_value(3.5);
Sourcepub fn get_track(&self, name: &str) -> Option<&Track>
pub fn get_track(&self, name: &str) -> Option<&Track>
Get track by name.
You should use get_track_mut
to create a track.
Sourcepub fn save_tracks(&self) -> Vec<Track>
pub fn save_tracks(&self) -> Vec<Track>
Create a clone of the tracks in the session which can then be serialized to a file in any
format with a serde implementation.
Tracks can be turned into a RocketPlayer
for playback.
Sourcepub fn set_row(&mut self, row: u32) -> Result<(), Error>
pub fn set_row(&mut self, row: u32) -> Result<(), Error>
Send a SetRow message.
This changes the current row on the tracker side.
§Errors
This method can return an Error::IOError
if Rocket tracker disconnects.
Sourcepub fn poll_events(&mut self) -> Result<Option<Event>, Error>
pub fn poll_events(&mut self) -> Result<Option<Event>, Error>
Poll for new events from the tracker.
This polls from events from the tracker.
You should call this fairly often your main loop.
It is recommended to keep calling this as long as your receive Some(Event)
.
§Errors
This method can return an Error::IOError
if Rocket tracker disconnects.
§Examples
while let Some(event) = rocket.poll_events().unwrap() {
match event {
// Do something with the various events.
_ => (),
}
}