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