xmtp_api_d14n/protocol/extractors/
depends_on.rs1use xmtp_proto::ConversionError;
4use xmtp_proto::types::GlobalCursor;
5use xmtp_proto::xmtp::xmtpv4::envelopes::ClientEnvelope;
6
7use crate::protocol::{EnvelopeVisitor, Extractor};
8
9#[derive(Default, Clone, Debug)]
13pub struct DependsOnExtractor {
14 cursor: Option<GlobalCursor>,
15}
16
17impl DependsOnExtractor {
18 pub fn new() -> Self {
19 Default::default()
20 }
21}
22
23impl Extractor for DependsOnExtractor {
24 type Output = Option<GlobalCursor>;
25
26 fn get(self) -> Self::Output {
27 self.cursor
28 }
29}
30
31impl EnvelopeVisitor<'_> for DependsOnExtractor {
32 type Error = ConversionError;
33
34 fn visit_client(&mut self, e: &ClientEnvelope) -> Result<(), Self::Error> {
35 self.cursor = e
38 .aad
39 .as_ref()
40 .and_then(|a| a.depends_on.clone().map(Into::into));
41 Ok(())
42 }
43}