src/lib.rs
//! fruitbasket - Framework for running Rust programs in a Mac 'app bundle' environment.
//!
//! fruitbasket provides two different (but related) services for helping you run your
//! Rust binaries as native AppKit/Cocoa applications on Mac OS X:
//!
//! * App lifecycle and environment API - fruitbasket provides an API to initialize the
//! AppKit application environment (NSApplication), to pump the main application loop
//! and dispatch Apple events in a non-blocking way, to terminate the application, to
//! access resources in the app bundle, and various other tasks frequently needed by
//! Mac applications.
//!
//! * Self-bundling app 'trampoline' - fruitbasket provides a 'trampoline' to
//! automatically bundle a standalone binary as a Mac application in a `.app` bundle
//! at runtime. This allows access to features that require running from a bundle (
//! such as XPC services), self-installing into the Applications folder, registering
//! your app with the system as a document type or URL handler, and various other
//! features that are only available to bundled apps with unique identifiers.
//! Self-bundling and relaunching itself (the "trampoline" behavior) allows your app
//! to get the features of app bundles, but still be launched in the standard Rust
//! ways (such as `cargo run`).
//!
//! The primary goal of fruitbasket is to make it reasonably easy to develop native
//! Mac GUI applications with the standard Apple AppKit/Cocoa/Foundation frameworks
//! in pure Rust by pushing all of the Apple and Objective-C runtime logic into
//! dedicated libraries, isolating the logic of a Rust binary application from the
//! unsafe platform code. As the ecosystem of Mac libraries for Rust grows, you
//! should be able to mix-and-match the libraries your application needs, pump the
//! event loop with fruitbasket, and never worry about Objective-C in your application.
//!
//! # Getting Started
//!
//! You likely want to create either a [Trampoline](struct.Trampoline.html) or a
//! [FruitApp](struct.FruitApp.html) right after your Rust application starts.
//! If uncertain, use a `Trampoline`. You can hit very strange behavior when running
//! Cocoa apps outside of an app bundle.
use Error;
use Duration;
use Sender;
use Receiver;
use thread;
extern crate time;
extern crate dirs;
extern crate objc;
extern crate log;
extern crate log4rs;
/// Info.plist entries that have default values, but can be overridden
///
/// These properties are always set in the app bundle's Property List, with the
/// default values provided here, but can be overridden by your application with
/// the Trampoline builder's `plist_key*()` functions.
pub const DEFAULT_PLIST: &'static = &;
/// Info.plist entries that are set, and cannot be overridden
///
/// These properties are always set in the app bundle's Property List, based on
/// information provided to the Trampoline builder, and cannot be overridden
/// with the builder's `plist_key*()` functions.
pub const FORBIDDEN_PLIST: &'static = & ;
/// Apple kInternetEventClass constant
pub const kInternetEventClass: u32 = 0x4755524c;
/// Apple kAEGetURL constant
pub const kAEGetURL: u32 = 0x4755524c;
/// Apple keyDirectObject constant
pub const keyDirectObject: u32 = 0x2d2d2d2d;
pub use FruitApp;
pub use Trampoline;
pub use FruitObjcCallback;
pub use FruitCallbackKey;
pub use parse_url_event;
pub use nsstring_to_string;
/// Docs in OS X build.
/// Docs in OS X build.
pub type FruitObjcCallback = ;
/// Main interface for controlling and interacting with the AppKit app
///
/// Dummy implementation for non-OSX platforms. See OS X build for proper
/// documentation.
/// Docs in OS X build.
/// Docs in OS X build.
/// API to move the executable into a Mac app bundle and relaunch (if necessary)
///
/// Dummy implementation for non-OSX platforms. See OS X build for proper
/// documentation.
/// Options for how long to run the event loop on each call
/// Policies controlling how a Mac application's UI is interacted with
/// Class for errors generated by fruitbasket. Dereferences to a String.
/// An opaque, thread-safe object that can interrupt the run loop.
///
/// An object that is safe to pass across thread boundaries (i.e. it implements
/// Send and Sync), and can be used to interrupt and stop the run loop, even
/// when running in 'Forever' mode. It can be Cloned infinite times and used
/// from any thread.
/// Options for where to save generated app bundle
/// Options for where to save logging output generated by fruitbasket
/// Enable logging to rolling log files with Rust `log` library
///
/// Requires the 'logging' feature to be specified at compile time.
///
/// This is a helper utility for configuring the Rust `log` and `log4rs`
/// libraries to redirect the `log` macros (`info!()`, `warn!()`, `err!()`, etc)
/// to both stdout and a rotating log file on disk.
///
/// If you specify the Home directory with a log named ".fruit.log" and a
/// backup count of 3, eventually you will end up with the files `~/.fruit.log`,
/// `~/.fruit.log.1`, `~/.fruit.log.2`, and `~/.fruit.log.3`
///
/// The maximum disk space used by the log files, in megabytes, will be:
///
/// `(backup_count + 1) * max_size_mb`
///
/// # Arguments
///
/// `filename` - Filename for the log file, *without* path
///
/// `dir` - Directory to save log files in. This is provided as an enum,
/// `LogDir`, which offers some standard logging directories, or allows
/// specification of any custom directory.
///
/// `max_size_mb` - Max size (in megabytes) of the log file before it is rolled
/// into an archive file in the same directory.
///
/// `backup_count` - Number of archived log files to keep before deleting old
/// logs.
///
/// # Returns
///
/// Full path to opened log file on disk
/// Enable logging to rolling log files with Rust `log` library
///
/// Requires the 'logging' feature to be specified at compile time.
///
/// This is a helper utility for configuring the Rust `log` and `log4rs`
/// libraries to redirect the `log` macros (`info!()`, `warn!()`, `error!()`, etc)
/// to both stdout and a rotating log file on disk.
///
/// If you specify the Home directory with a log named ".fruit.log" and a
/// backup count of 3, eventually you will end up with the files `~/.fruit.log`,
/// `~/.fruit.log.1`, `~/.fruit.log.2`, and `~/.fruit.log.3`
///
/// The maximum disk space used by the log files, in megabytes, will be:
///
/// `(backup_count + 1) * max_size_mb`
///
/// # Arguments
///
/// `filename` - Filename for the log file, *without* path
///
/// `dir` - Directory to save log files in. This is provided as an enum,
/// `LogDir`, which offers some standard logging directories, or allows
/// specification of any custom directory.
///
/// `max_size_mb` - Max size (in megabytes) of the log file before it is rolled
/// into an archive file in the same directory.
///
/// `backup_count` - Number of archived log files to keep before deleting old
/// logs.
///
/// # Returns
///
/// Full path to opened log file on disk