pub struct ZelloClient { /* private fields */ }Expand description
Zello client for interacting with the Zello API
Implementations§
Source§impl ZelloClient
Zello client for interacting with the Zello API
impl ZelloClient
Zello client for interacting with the Zello API
Sourcepub async fn new(config: ZelloConfig) -> Result<Self>
pub async fn new(config: ZelloConfig) -> Result<Self>
Create a new Zello client and connect
#Errors
Returns an error if fail to create a new Zello client
Sourcepub async fn run_message_loop(
&mut self,
decoder: Arc<Mutex<Decoder>>,
pcm_tx: &Sender<Vec<i16>>,
) -> Result<()>
pub async fn run_message_loop( &mut self, decoder: Arc<Mutex<Decoder>>, pcm_tx: &Sender<Vec<i16>>, ) -> Result<()>
Examples found in repository?
examples/complete.rs (line 84)
59async fn main() -> Result<()> {
60 let args = Args::parse();
61
62 load_dotenv_from_file("examples/.env.example")?;
63 initialize_logging()?;
64
65 let credentials = load_credentials()?;
66 let decoder = create_decoder()?;
67
68 let (pcm_tx, pcm_rx) = bounded::<Vec<i16>>(PCM_CHANNEL_CAPACITY);
69 let pcm_rx = Arc::new(Mutex::new(pcm_rx));
70 let _stream = setup_audio_output(pcm_rx)?;
71
72 let mut client = connect_to_zello(&credentials).await?;
73
74 match (args.message, args.callsign) {
75 (Some(msg), Some(callsign)) => {
76 client
77 .send_text_message_to_callsign(&msg, &callsign)
78 .await?;
79 }
80 (Some(msg), None) => {
81 client.send_text_message(&msg).await?;
82 }
83 (None, _) => {
84 client.run_message_loop(decoder, &pcm_tx).await?;
85 }
86 }
87
88 client.close().await?;
89
90 Ok(())
91}Sourcepub async fn send_text_message(&mut self, text: &str) -> Result<()>
pub async fn send_text_message(&mut self, text: &str) -> Result<()>
Send a text message to the channel
§Errors
Returns an error if fail to send a text message to the channel
Examples found in repository?
More examples
examples/complete.rs (line 81)
59async fn main() -> Result<()> {
60 let args = Args::parse();
61
62 load_dotenv_from_file("examples/.env.example")?;
63 initialize_logging()?;
64
65 let credentials = load_credentials()?;
66 let decoder = create_decoder()?;
67
68 let (pcm_tx, pcm_rx) = bounded::<Vec<i16>>(PCM_CHANNEL_CAPACITY);
69 let pcm_rx = Arc::new(Mutex::new(pcm_rx));
70 let _stream = setup_audio_output(pcm_rx)?;
71
72 let mut client = connect_to_zello(&credentials).await?;
73
74 match (args.message, args.callsign) {
75 (Some(msg), Some(callsign)) => {
76 client
77 .send_text_message_to_callsign(&msg, &callsign)
78 .await?;
79 }
80 (Some(msg), None) => {
81 client.send_text_message(&msg).await?;
82 }
83 (None, _) => {
84 client.run_message_loop(decoder, &pcm_tx).await?;
85 }
86 }
87
88 client.close().await?;
89
90 Ok(())
91}Sourcepub async fn send_text_message_to_callsign(
&mut self,
text: &str,
callsign: &str,
) -> Result<()>
pub async fn send_text_message_to_callsign( &mut self, text: &str, callsign: &str, ) -> Result<()>
Send a text message to the channel
§Errors
Returns an error if fail to send a text message to the channel
Examples found in repository?
examples/complete.rs (line 77)
59async fn main() -> Result<()> {
60 let args = Args::parse();
61
62 load_dotenv_from_file("examples/.env.example")?;
63 initialize_logging()?;
64
65 let credentials = load_credentials()?;
66 let decoder = create_decoder()?;
67
68 let (pcm_tx, pcm_rx) = bounded::<Vec<i16>>(PCM_CHANNEL_CAPACITY);
69 let pcm_rx = Arc::new(Mutex::new(pcm_rx));
70 let _stream = setup_audio_output(pcm_rx)?;
71
72 let mut client = connect_to_zello(&credentials).await?;
73
74 match (args.message, args.callsign) {
75 (Some(msg), Some(callsign)) => {
76 client
77 .send_text_message_to_callsign(&msg, &callsign)
78 .await?;
79 }
80 (Some(msg), None) => {
81 client.send_text_message(&msg).await?;
82 }
83 (None, _) => {
84 client.run_message_loop(decoder, &pcm_tx).await?;
85 }
86 }
87
88 client.close().await?;
89
90 Ok(())
91}Sourcepub async fn start_audio_stream(
&mut self,
codec: &str,
packet_duration: u32,
) -> Result<u32>
pub async fn start_audio_stream( &mut self, codec: &str, packet_duration: u32, ) -> Result<u32>
Sourcepub async fn stop_audio_stream(&mut self, stream_id: u32) -> Result<()>
pub async fn stop_audio_stream(&mut self, stream_id: u32) -> Result<()>
Sourcepub async fn receive_message(&mut self) -> Result<Option<IncomingMessage>>
pub async fn receive_message(&mut self) -> Result<Option<IncomingMessage>>
Sourcepub fn is_authenticated(&self) -> bool
pub fn is_authenticated(&self) -> bool
Check if client is authenticated
Sourcepub async fn close(self) -> Result<()>
pub async fn close(self) -> Result<()>
Examples found in repository?
More examples
examples/complete.rs (line 88)
59async fn main() -> Result<()> {
60 let args = Args::parse();
61
62 load_dotenv_from_file("examples/.env.example")?;
63 initialize_logging()?;
64
65 let credentials = load_credentials()?;
66 let decoder = create_decoder()?;
67
68 let (pcm_tx, pcm_rx) = bounded::<Vec<i16>>(PCM_CHANNEL_CAPACITY);
69 let pcm_rx = Arc::new(Mutex::new(pcm_rx));
70 let _stream = setup_audio_output(pcm_rx)?;
71
72 let mut client = connect_to_zello(&credentials).await?;
73
74 match (args.message, args.callsign) {
75 (Some(msg), Some(callsign)) => {
76 client
77 .send_text_message_to_callsign(&msg, &callsign)
78 .await?;
79 }
80 (Some(msg), None) => {
81 client.send_text_message(&msg).await?;
82 }
83 (None, _) => {
84 client.run_message_loop(decoder, &pcm_tx).await?;
85 }
86 }
87
88 client.close().await?;
89
90 Ok(())
91}Sourcepub fn add_inbound_stream(
&mut self,
stream_id: u32,
channel: String,
codec: String,
callsign: Option<String>,
) -> Result<()>
pub fn add_inbound_stream( &mut self, stream_id: u32, channel: String, codec: String, callsign: Option<String>, ) -> Result<()>
Sourcepub fn get_inbound_stream(&self, stream_id: u32) -> Option<&StreamInfo>
pub fn get_inbound_stream(&self, stream_id: u32) -> Option<&StreamInfo>
Get an inbound stream from the client
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for ZelloClient
impl !RefUnwindSafe for ZelloClient
impl Send for ZelloClient
impl Sync for ZelloClient
impl Unpin for ZelloClient
impl !UnwindSafe for ZelloClient
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more