Skip to main content

imsg_pbap/
lib.rs

1//! PBAP protocol logic — contact pull and vCard retrieval.
2
3pub mod client;
4pub mod contacts;
5pub mod params;
6pub mod phonebook;
7
8pub use contacts::normalize_number;
9pub use contacts::CardEntry;
10pub use contacts::CardListingError;
11pub use formats::vcard::{Contact, ContactError};
12pub use obex_core::client::ObexError;
13pub use obex_core::TransportError;
14
15use thiserror::Error;
16
17/// PBAP client errors — OBEX, transport, server response, vCard parse, XML listing parse, and input validation.
18#[derive(Debug, Error)]
19pub enum PbapError {
20    /// Connection state violation, packet codec failure, or server rejection.
21    #[error("OBEX: {0}")]
22    Obex(#[from] ObexError),
23    /// Framing error or OS-level socket failure.
24    #[error("transport: {0}")]
25    Transport(#[from] TransportError),
26    /// Remote device returned a non-OK response opcode; inner byte is the opcode.
27    #[error("server returned error opcode {0:#04x}")]
28    ServerError(u8),
29    /// Transport stream ended before a complete packet was received.
30    #[error("unexpected end of stream")]
31    UnexpectedEof,
32    /// Response body exceeded the 4 MiB safety ceiling.
33    #[error("response body too large")]
34    ResponseTooLarge,
35    /// Response body is not valid UTF-8; cannot parse as vCard text.
36    #[error("response body is not UTF-8")]
37    InvalidEncoding,
38    /// calcard failed to parse a vCard in the response body.
39    #[error("vCard parse error: {0}")]
40    Contact(#[from] ContactError),
41    /// Remote vCard-listing XML was malformed or a `<card>` element lacked the required `handle` attribute.
42    #[error("card listing: {0}")]
43    CardListing(#[from] CardListingError),
44    /// A user-supplied parameter failed wire-format validation; inner message names the violated constraint.
45    #[error("invalid input: {0}")]
46    InvalidInput(&'static str),
47}