Skip to main content

Crate intents

Crate intents 

Source
Expand description

§intents

Safe Rust bindings for Apple’s Intents framework on macOS.

Status: v0.3.3 keeps the async API module (Tier 1) and adds broad rustdoc coverage across the public sync + async surface.

§Quick start

use intents::prelude::*;

fn main() {
    let status = Preferences::siri_authorization_status();
    println!("Siri authorization status: {status:?}");
}

§Async API

Enable the async feature for executor-agnostic Future wrappers over every Intents.framework completion-handler API:

[dependencies]
intents = { version = "0.3", features = ["async"] }
#[cfg(feature = "async")]
fn main() -> Result<(), Box<dyn std::error::Error>> {
    use intents::async_api::AsyncInteraction;
    use intents::{Intent, Interaction};

    pollster::block_on(async {
        // Donate an interaction
        let intent = Intent::new()?;
        let interaction = Interaction::new(&intent, None)?;
        AsyncInteraction::donate(&interaction).await?;

        // Delete all interactions
        AsyncInteraction::delete_all().await?;

        Ok::<_, Box<dyn std::error::Error>>(())
    })
}

#[cfg(not(feature = "async"))]
fn main() {}

§Async API surface

Entry pointFuture typeSwift API
AsyncInteraction::donateInteractionDonateFutureINInteraction.donate(completion:)
AsyncInteraction::deleteInteractionDeleteFutureINInteraction.delete(with:[String],completion:)
AsyncInteraction::delete_by_groupInteractionDeleteFutureINInteraction.delete(with:String,completion:)
AsyncInteraction::delete_allInteractionDeleteAllFutureINInteraction.deleteAll(completion:)
AsyncPreferences::request_siri_authorizationSiriAuthorizationFutureINPreferences.requestSiriAuthorization(_:)
AsyncVoiceShortcutCenter::get_allAllVoiceShortcutsFutureINVoiceShortcutCenter.getAllVoiceShortcuts(completion:)
AsyncVoiceShortcutCenter::getVoiceShortcutFutureINVoiceShortcutCenter.getVoiceShortcut(with:completion:)

§Highlights

  • Core intent, response, donation, shortcut, interaction, vocabulary, relevant-shortcut, file, person, and voice-shortcut APIs from v0.1.0–v0.2.1 remain available.
  • Support and model helpers for CLPlacemark (INIntentsAdditions), NSString (Intents), NSUserActivity (IntentsAdditions), INObjectSection, INObjectCollection, IntentsVersionNumber, and IntentsVersionString.
  • Call, focus, message, and reservation/travel wrappers including INCall*, INFocusStatus*, INMessage*, INSticker*, INAirline, INAirport, INFlight, INPaymentMethod, INReservationAction, INSeat, and INTicketedEvent.
  • Additional Siri intent families: INAnswerCallIntent, INEditMessageIntent, INGetReservationDetailsIntent, INHangUpCallIntent, INShareFocusStatusIntent, and INUnsendMessagesIntent, along with their response enums and handling helpers.
  • Extra resolution-result families plus INIntentResolutionResult (Custom) helpers and INIntentErrorCode coverage.

§Examples

cargo run --example 01_smoke
cargo run --example 21_intent_extras_roundtrip
cargo run --example 25_intent_error_codes
# async examples
cargo run --features async --example 26_async_interaction
cargo run --features async --example 27_async_preferences
cargo run --features async --example 28_async_voice_shortcuts

The crate ships 28 numbered examples and 25 integration-test files.

§Coverage

See COVERAGE_AUDIT.md for the current v0.2.2 SDK symbol audit, and COVERAGE.md for the logical-area coverage notes.

§Notes

  • Apple still marks several Siri suggestion APIs as unavailable in the macOS headers even though the Objective-C runtime exposes them. This crate keeps the existing runtime-backed wrappers for INPreferences, INParameter, INVocabulary, INRelevantShortcut*, INRelevanceProvider*, INPlayMediaIntent, INSearchForMessagesIntent, and INAddTasksIntent.
  • Restaurant-booking-only types such as INRestaurantReservationBooking and the related response enums remain EXEMPT because the macOS SDK marks them unavailable.
  • NSUserActivity.shortcutAvailability and NSExtensionContext (ShareExtension) are also unavailable on macOS and are documented as exempt rather than wrapped.
  • INShortcut created from NSUserActivity needs a title to avoid framework validation warnings. The bridge assigns the activity type as the activity title automatically.

§License

Licensed under either of Apache-2.0 or MIT at your option.

Re-exports§

pub use call::CallAudioRoute;
pub use call::CallCapability;
pub use call::CallCapabilityOptions;
pub use call::CallDestinationType;
pub use call::CallGroup;
pub use call::CallRecord;
pub use call::CallRecordFilter;
pub use call::CallRecordType;
pub use call::CallRecordTypeOptions;
pub use error::IntentsError;
pub use error_code::IntentErrorCode;
pub use focus::FocusStatus;
pub use focus::FocusStatusAuthorizationStatus;
pub use focus::FocusStatusCenter;
pub use handler_extras::AnswerCallIntentHandling;
pub use handler_extras::EditMessageIntentHandling;
pub use handler_extras::HangUpCallIntentHandling;
pub use handler_extras::SendMessageIntentHandling;
pub use handler_extras::ShareFocusStatusIntentHandling;
pub use handler_extras::UnsendMessagesIntentHandling;
pub use in_file::IntentFile;
pub use in_interaction::DateInterval;
pub use in_interaction::IntentHandlingStatus;
pub use in_interaction::Interaction;
pub use in_interaction::InteractionDirection;
pub use in_object::Image;
pub use in_object::IntentObject;
pub use in_object::Speakable;
pub use in_object::SpeakableString;
pub use in_parameter::IntentParameter;
pub use in_person::Person;
pub use in_person::PersonHandle;
pub use in_person::PersonHandleType;
pub use in_person::PersonSuggestionType;
pub use in_relevant_shortcut::DailyRoutineSituation;
pub use in_relevant_shortcut::RelevanceProvider;
pub use in_relevant_shortcut::RelevantShape;
pub use in_relevant_shortcut::RelevantShortcut;
pub use in_relevant_shortcut::RelevantShortcutRole;
pub use in_relevant_shortcut_store::RelevantShortcutStore;
pub use in_vocabulary::IntentVocabulary;
pub use in_vocabulary::VocabularyStringType;
pub use intent_definition::AddTasksIntent;
pub use intent_definition::Intent;
pub use intent_definition::PlayMediaIntent;
pub use intent_definition::SearchForMessagesIntent;
pub use intent_definition::SendMessageIntent;
pub use intent_definition::SetTimerIntent;
pub use intent_definition::Shortcut;
pub use intent_definition::StartCallIntent;
pub use intent_donation::IntentDonationMetadata;
pub use intent_donation::SendMessageIntentDonationMetadata;
pub use intent_extension::IntentExtension;
pub use intent_extras::AnswerCallIntent;
pub use intent_extras::EditMessageIntent;
pub use intent_extras::GetReservationDetailsIntent;
pub use intent_extras::HangUpCallIntent;
pub use intent_extras::ShareFocusStatusIntent;
pub use intent_extras::UnsendMessagesIntent;
pub use intent_handler::IntentHandlerProvider;
pub use intent_handler::StartCallIntentHandling;
pub use intent_resolution::IntentResolutionResult;
pub use intent_response::IntentResponse;
pub use intent_response::SendMessageIntentResponse;
pub use intent_response::SendMessageIntentResponseCode;
pub use intent_response::UserActivity;
pub use message::MessageLinkMetadata;
pub use message::MessageReaction;
pub use message::MessageReactionType;
pub use message::OutgoingMessageType;
pub use message::SendMessageAttachment;
pub use message::Sticker;
pub use message::StickerType;
pub use preferences::Preferences;
pub use preferences::SiriAuthorizationStatus;
pub use reservation::Airline;
pub use reservation::Airport;
pub use reservation::AirportGate;
pub use reservation::BoatReservation;
pub use reservation::BoatTrip;
pub use reservation::BusReservation;
pub use reservation::BusTrip;
pub use reservation::CurrencyAmount;
pub use reservation::DateComponentsRange;
pub use reservation::Flight;
pub use reservation::FlightReservation;
pub use reservation::LodgingReservation;
pub use reservation::PaymentMethod;
pub use reservation::PaymentMethodType;
pub use reservation::RecurrenceFrequency;
pub use reservation::RentalCar;
pub use reservation::RentalCarReservation;
pub use reservation::Reservation;
pub use reservation::ReservationAction;
pub use reservation::ReservationActionType;
pub use reservation::ReservationStatus;
pub use reservation::RestaurantReservation;
pub use reservation::Seat;
pub use reservation::TicketedEvent;
pub use reservation::TicketedEventCategory;
pub use reservation::TicketedEventReservation;
pub use reservation::TrainReservation;
pub use reservation::TrainTrip;
pub use resolution_extras::BooleanResolutionResult;
pub use resolution_extras::CallCapabilityResolutionResult;
pub use resolution_extras::CallDestinationTypeResolutionResult;
pub use resolution_extras::CallRecordResolutionResult;
pub use resolution_extras::CallRecordTypeOptionsResolutionResult;
pub use resolution_extras::CallRecordTypeResolutionResult;
pub use resolution_extras::CurrencyAmountResolutionResult;
pub use resolution_extras::DateComponentsResolutionResult;
pub use resolution_extras::DoubleResolutionResult;
pub use resolution_extras::EnergyResolutionResult;
pub use resolution_extras::EnumResolutionResult;
pub use resolution_extras::FileResolutionResult;
pub use resolution_extras::IntegerResolutionResult;
pub use resolution_extras::LengthResolutionResult;
pub use resolution_extras::MassResolutionResult;
pub use resolution_extras::ObjectResolutionResult;
pub use resolution_extras::OutgoingMessageTypeResolutionResult;
pub use resolution_extras::PaymentMethodResolutionResult;
pub use resolution_extras::PersonResolutionResult;
pub use resolution_extras::PlacemarkResolutionResult;
pub use resolution_extras::SendMessageRecipientResolutionResult;
pub use resolution_extras::SendMessageRecipientUnsupportedReason;
pub use resolution_extras::SpeedResolutionResult;
pub use resolution_extras::StartCallCallRecordToCallBackResolutionResult;
pub use resolution_extras::StartCallCallRecordToCallBackUnsupportedReason;
pub use resolution_extras::StringResolutionResult;
pub use resolution_extras::TemperatureResolutionResult;
pub use resolution_extras::TimeIntervalResolutionResult;
pub use resolution_extras::URLResolutionResult;
pub use resolution_extras::VolumeResolutionResult;
pub use response_extras::AnswerCallIntentResponse;
pub use response_extras::AnswerCallIntentResponseCode;
pub use response_extras::EditMessageIntentResponse;
pub use response_extras::EditMessageIntentResponseCode;
pub use response_extras::GetReservationDetailsIntentResponse;
pub use response_extras::GetReservationDetailsIntentResponseCode;
pub use response_extras::HangUpCallIntentResponse;
pub use response_extras::HangUpCallIntentResponseCode;
pub use response_extras::ShareFocusStatusIntentResponse;
pub use response_extras::ShareFocusStatusIntentResponseCode;
pub use response_extras::UnsendMessagesIntentResponse;
pub use response_extras::UnsendMessagesIntentResponseCode;
pub use support::deferred_localized_intents_string;
pub use support::deferred_localized_intents_string_from_table;
pub use support::intents_version_number;
pub use support::intents_version_string;
pub use support::ObjectCollection;
pub use support::ObjectSection;
pub use support::Placemark;
pub use voice_shortcut::VoiceShortcut;
pub use voice_shortcut::VoiceShortcutCenter;

Modules§

async_apiasync
Async wrappers over callback-based Intents.framework APIs. Async API for the Intents framework.
call
Wrappers for INCall* types and related enums from Intents.framework.
error
Error types used by the safe Intents.framework bindings.
error_code
Rust mirrors of INIntentErrorCode values from Intents.framework.
ffi
Low-level FFI bindings used to call into Intents.framework.
focus
Wrappers for INFocusStatus* types from Intents.framework.
handler_extras
Helpers for IN*IntentHandling protocols from Intents.framework.
in_file
Wrappers for INFile from Intents.framework.
in_interaction
Wrappers for INInteraction and related enums from Intents.framework.
in_object
Wrappers for INObject, INImage, and INSpeakable* types.
in_parameter
Wrappers for INParameter from Intents.framework.
in_person
Wrappers for INPerson* types from Intents.framework.
in_relevant_shortcut
Wrappers for INRelevantShortcut* types from Intents.framework.
in_relevant_shortcut_store
Wrappers for INRelevantShortcutStore from Intents.framework.
in_vocabulary
Wrappers for INVocabulary and related enums from Intents.framework.
intent
Re-exported INIntent wrapper types.
intent_definition
Wrappers for INIntent, INShortcut, and typed intent classes.
intent_donation
Wrappers for INIntentDonationMetadata types.
intent_extension
Wrappers for INExtension from Intents.framework.
intent_extras
Wrappers for additional Siri intent families from Intents.framework.
intent_handler
Wrappers for INIntentHandlerProviding and related helpers.
intent_resolution
Wrappers for INIntentResolutionResult from Intents.framework.
intent_response
Wrappers for INIntentResponse and related response types.
interaction
Re-exported INInteraction wrapper types.
message
Wrappers for INMessage* and related messaging types.
preferences
Wrappers for INPreferences authorization APIs.
prelude
Convenience re-exports for the main Intents.framework wrapper types.
relevant
Re-exported INRelevantShortcut* wrapper types.
reservation
Wrappers for reservation, travel, and payment types from Intents.framework.
resolution_extras
Wrappers for typed INIntentResolutionResult subclasses.
response_extras
Wrappers for additional typed INIntentResponse subclasses.
support
Support wrappers and exported constants from Intents.framework.
voice_shortcut
Wrappers for INVoiceShortcut and INVoiceShortcutCenter.