pub struct ResponseSlot(pub Mutex<RefCell<Response>>, pub Notify, _);Expand description
The response slot for each UDS request This struct holds the response data and a notification object to signal when the response is ready
Tuple Fields§
§0: Mutex<RefCell<Response>>§1: NotifyImplementations§
Source§impl ResponseSlot
impl ResponseSlot
Sourcepub fn new(timeout_ms: Option<u64>) -> Self
pub fn new(timeout_ms: Option<u64>) -> Self
Create a new ResponseSlot.
This will initialize the slot with a default error (NotSupported) and set up the notification system.
The timeout_ms is an optional input in milisecs, the default timeout is 1000ms.
Sourcepub async fn get(&self) -> Result<Response, DiagError>
pub async fn get(&self) -> Result<Response, DiagError>
Get a response in a blocking manner. This will block forever until a response is available.
It waits for the notification to be triggered and then locks the Mutex to retrieve the response.
Sourcepub async fn wait_for_response(&self) -> Response
pub async fn wait_for_response(&self) -> Response
Get a response with a timeout. If no response is received within the timeout period, an error is returned.
This function uses tokio::select! to wait for either the notification or the timeout.
If the timeout expires, it returns a Timeout error.
Sourcepub async fn update_response(&self, new_data: Vec<u8>)
pub async fn update_response(&self, new_data: Vec<u8>)
Update the response data in the response slot and notify the waiting task.
This function is used to update the response after receiving new data.
It creates a UdsFrame from the provided new_data and replaces the current response data.
After updating, it notifies the waiting task that the response is ready.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for ResponseSlot
impl !RefUnwindSafe for ResponseSlot
impl !UnwindSafe for ResponseSlot
impl Send for ResponseSlot
impl Sync for ResponseSlot
impl Unpin for ResponseSlot
impl UnsafeUnpin for ResponseSlot
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
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more