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 point | Future type | Swift API |
|---|---|---|
AsyncInteraction::donate | InteractionDonateFuture | INInteraction.donate(completion:) |
AsyncInteraction::delete | InteractionDeleteFuture | INInteraction.delete(with:[String],completion:) |
AsyncInteraction::delete_by_group | InteractionDeleteFuture | INInteraction.delete(with:String,completion:) |
AsyncInteraction::delete_all | InteractionDeleteAllFuture | INInteraction.deleteAll(completion:) |
AsyncPreferences::request_siri_authorization | SiriAuthorizationFuture | INPreferences.requestSiriAuthorization(_:) |
AsyncVoiceShortcutCenter::get_all | AllVoiceShortcutsFuture | INVoiceShortcutCenter.getAllVoiceShortcuts(completion:) |
AsyncVoiceShortcutCenter::get | VoiceShortcutFuture | INVoiceShortcutCenter.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, andIntentsVersionString. - Call, focus, message, and reservation/travel wrappers including
INCall*,INFocusStatus*,INMessage*,INSticker*,INAirline,INAirport,INFlight,INPaymentMethod,INReservationAction,INSeat, andINTicketedEvent. - Additional Siri intent families:
INAnswerCallIntent,INEditMessageIntent,INGetReservationDetailsIntent,INHangUpCallIntent,INShareFocusStatusIntent, andINUnsendMessagesIntent, along with their response enums and handling helpers. - Extra resolution-result families plus
INIntentResolutionResult (Custom)helpers andINIntentErrorCodecoverage.
§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_shortcutsThe 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, andINAddTasksIntent. - Restaurant-booking-only types such as
INRestaurantReservationBookingand the related response enums remainEXEMPTbecause the macOS SDK marks them unavailable. NSUserActivity.shortcutAvailabilityandNSExtensionContext (ShareExtension)are also unavailable on macOS and are documented as exempt rather than wrapped.INShortcutcreated fromNSUserActivityneeds 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::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::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::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_
api async - Async wrappers over callback-based Intents.framework APIs.
Async API for the
Intentsframework. - 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
INIntentErrorCodevalues 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*IntentHandlingprotocols from Intents.framework. - in_file
- Wrappers for
INFilefrom Intents.framework. - in_
interaction - Wrappers for
INInteractionand related enums from Intents.framework. - in_
object - Wrappers for
INObject,INImage, andINSpeakable*types. - in_
parameter - Wrappers for
INParameterfrom 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
INRelevantShortcutStorefrom Intents.framework. - in_
vocabulary - Wrappers for
INVocabularyand related enums from Intents.framework. - intent
- Re-exported
INIntentwrapper types. - intent_
definition - Wrappers for
INIntent,INShortcut, and typed intent classes. - intent_
donation - Wrappers for
INIntentDonationMetadatatypes. - intent_
extension - Wrappers for
INExtensionfrom Intents.framework. - intent_
extras - Wrappers for additional Siri intent families from Intents.framework.
- intent_
handler - Wrappers for
INIntentHandlerProvidingand related helpers. - intent_
resolution - Wrappers for
INIntentResolutionResultfrom Intents.framework. - intent_
response - Wrappers for
INIntentResponseand related response types. - interaction
- Re-exported
INInteractionwrapper types. - message
- Wrappers for
INMessage*and related messaging types. - preferences
- Wrappers for
INPreferencesauthorization 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
INIntentResolutionResultsubclasses. - response_
extras - Wrappers for additional typed
INIntentResponsesubclasses. - support
- Support wrappers and exported constants from Intents.framework.
- voice_
shortcut - Wrappers for
INVoiceShortcutandINVoiceShortcutCenter.