Skip to main content

docan_rs/client/service/
read_did.rs

1//! response of Service 22
2
3use crate::{client::DoCanClient, DoCanResult};
4use iso14229_1::{request, response, DataIdentifier, Service};
5use iso15765_2::can::AddressType;
6use rs_can::{CanDevice, CanFrame};
7use std::{fmt::Display, hash::Hash};
8
9impl<D, C, F> DoCanClient<D, C, F>
10where
11    D: CanDevice<Channel = C, Frame = F> + Clone + Send + 'static,
12    C: Clone + Eq + Display + Hash + Send + Sync + 'static,
13    F: CanFrame<Channel = C> + Clone + Display + 'static,
14{
15    pub async fn read_data_by_identifier(
16        &mut self,
17        did: DataIdentifier,
18        others: Vec<DataIdentifier>,
19    ) -> DoCanResult<response::ReadDID> {
20        let data = request::ReadDID::new(did, others);
21        let cfg = self.context.get_cfg().await;
22        let request = Self::make_request(Service::ReadDID, None, data, &cfg)?;
23
24        self.send_and_parse(AddressType::Physical, request, None, &cfg)
25            .await
26    }
27}