QBToRef

Trait QBToRef 

Source
pub trait QBToRef: QBItem {
    // Required method
    fn to_ref(&self) -> Result<NtRef, QBTypeError>;
}
Expand description

Trait for entities that can be converted to QuickBooks entity references.

Entity references (NtRef) are used throughout QuickBooks to link entities together. For example, an invoice has a customer reference that points to a specific customer.

§Required Methods

  • to_ref(): Converts the entity to an NtRef for use in other entities

§Returns

Returns a Result<NtRef, QBTypeError> where:

  • Ok(NtRef) if the entity can be referenced (has ID and name field)
  • Err(QBTypeError::QBToRefError) if the entity cannot be referenced

§Examples

use quickbooks_types::{Invoice, Customer, QBToRef};

let mut customer = Customer::default();
customer.id = Some("123".to_string());
customer.display_name = Some("John Doe".to_string());

// Convert to reference for use in other entities
let customer_ref = customer.to_ref().unwrap();

// Use the reference in an invoice
let mut invoice = Invoice::default();
invoice.customer_ref = Some(customer_ref);

Required Methods§

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§