QBItem

Trait QBItem 

Source
pub trait QBItem:
    Serialize
    + Default
    + Clone
    + Sized
    + DeserializeOwned
    + Debug
    + Send {
    // Required methods
    fn id(&self) -> Option<&String>;
    fn clone_id(&self) -> Option<String>;
    fn sync_token(&self) -> Option<&String>;
    fn meta_data(&self) -> Option<&MetaData>;
    fn name() -> &'static str;
    fn qb_id() -> &'static str;

    // Provided method
    fn has_read(&self) -> bool { ... }
}
Expand description

Core trait for all QuickBooks entities.

This trait defines the fundamental interface that all QuickBooks entities must implement. It provides access to common fields like ID, sync token, and metadata that are present on all QuickBooks objects, as well as type information for API operations.

§Required Methods

  • id(): Returns the entity’s unique identifier
  • clone_id(): Returns a cloned copy of the ID
  • sync_token(): Returns the synchronization token for updates
  • meta_data(): Returns metadata about the entity
  • name(): Returns the entity type name for API calls
  • qb_id(): Returns the lowercase entity identifier for URLs

§Default Methods

  • has_read(): Returns true if the entity has both ID and sync token (indicates it was read from QB)

§Examples

use quickbooks_types::{QBItem, Customer};

let customer = Customer::default();

// Check if entity has been read from QuickBooks
if customer.has_read() {
    println!("Customer ID: {:?}", customer.id());
    println!("Sync Token: {:?}", customer.sync_token());
}

// Get type information
println!("Entity name: {}", Customer::name()); // "Customer"
println!("API identifier: {}", Customer::qb_id()); // "customer"

Required Methods§

Source

fn id(&self) -> Option<&String>

Source

fn clone_id(&self) -> Option<String>

Source

fn sync_token(&self) -> Option<&String>

Source

fn meta_data(&self) -> Option<&MetaData>

Source

fn name() -> &'static str

Source

fn qb_id() -> &'static str

Provided Methods§

Source

fn has_read(&self) -> bool

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§