pub struct EspHomeClient { /* private fields */ }
Implementations§
Source§impl EspHomeClient
impl EspHomeClient
Sourcepub fn builder() -> EspHomeClientBuilder
pub fn builder() -> EspHomeClientBuilder
Creates a new builder for configuring and connecting to an ESPHome API server.
Sourcepub async fn try_write<M>(&mut self, message: M) -> Result<(), ClientError>
pub async fn try_write<M>(&mut self, message: M) -> Result<(), ClientError>
Sends a message to the ESPHome device.
§Errors
Will return an error if the write operation fails for example due to a disconnected stream.
Sourcepub async fn try_read(&mut self) -> Result<EspHomeMessage, ClientError>
pub async fn try_read(&mut self) -> Result<EspHomeMessage, ClientError>
Reads the next message from the stream.
It will automatically handle ping requests if ping handling is enabled.
§Errors
Will return an error if the read operation fails, for example due to a disconnected stream
Sourcepub async fn close(self) -> Result<(), ClientError>
pub async fn close(self) -> Result<(), ClientError>
Closes the connection gracefully by sending a DisconnectRequest
message.
§Errors
Will return an error if the write operation fails, for example due to a disconnected stream
Sourcepub fn write_stream(&self) -> EspHomeClientWriteStream
pub fn write_stream(&self) -> EspHomeClientWriteStream
Returns a clone-able write stream for sending messages to the ESPHome device.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for EspHomeClient
impl !RefUnwindSafe for EspHomeClient
impl Send for EspHomeClient
impl Sync for EspHomeClient
impl Unpin for EspHomeClient
impl !UnwindSafe for EspHomeClient
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