Source code
Revision control
Copy as Markdown
Other Tools
//! This file has been automatically generated by `objc2`'s `header-translator`.
//! DO NOT EDIT
use core::ffi::*;
use core::ptr::NonNull;
use objc2::__framework_prelude::*;
use crate::*;
/// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsrelativedatetimeformatterstyle?language=objc)
// NS_ENUM
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct NSRelativeDateTimeFormatterStyle(pub NSInteger);
impl NSRelativeDateTimeFormatterStyle {
#[doc(alias = "NSRelativeDateTimeFormatterStyleNumeric")]
pub const Numeric: Self = Self(0);
#[doc(alias = "NSRelativeDateTimeFormatterStyleNamed")]
pub const Named: Self = Self(1);
}
unsafe impl Encode for NSRelativeDateTimeFormatterStyle {
const ENCODING: Encoding = NSInteger::ENCODING;
}
unsafe impl RefEncode for NSRelativeDateTimeFormatterStyle {
const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}
/// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsrelativedatetimeformatterunitsstyle?language=objc)
// NS_ENUM
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct NSRelativeDateTimeFormatterUnitsStyle(pub NSInteger);
impl NSRelativeDateTimeFormatterUnitsStyle {
#[doc(alias = "NSRelativeDateTimeFormatterUnitsStyleFull")]
pub const Full: Self = Self(0);
#[doc(alias = "NSRelativeDateTimeFormatterUnitsStyleSpellOut")]
pub const SpellOut: Self = Self(1);
#[doc(alias = "NSRelativeDateTimeFormatterUnitsStyleShort")]
pub const Short: Self = Self(2);
#[doc(alias = "NSRelativeDateTimeFormatterUnitsStyleAbbreviated")]
pub const Abbreviated: Self = Self(3);
}
unsafe impl Encode for NSRelativeDateTimeFormatterUnitsStyle {
const ENCODING: Encoding = NSInteger::ENCODING;
}
unsafe impl RefEncode for NSRelativeDateTimeFormatterUnitsStyle {
const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}
extern_class!(
/// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsrelativedatetimeformatter?language=objc)
#[unsafe(super(NSFormatter, NSObject))]
#[derive(Debug, PartialEq, Eq, Hash)]
#[cfg(feature = "NSFormatter")]
pub struct NSRelativeDateTimeFormatter;
);
#[cfg(all(feature = "NSFormatter", feature = "NSObject"))]
extern_conformance!(
unsafe impl NSCoding for NSRelativeDateTimeFormatter {}
);
#[cfg(all(feature = "NSFormatter", feature = "NSObject"))]
extern_conformance!(
unsafe impl NSCopying for NSRelativeDateTimeFormatter {}
);
#[cfg(all(feature = "NSFormatter", feature = "NSObject"))]
unsafe impl CopyingHelper for NSRelativeDateTimeFormatter {
type Result = Self;
}
#[cfg(feature = "NSFormatter")]
extern_conformance!(
unsafe impl NSObjectProtocol for NSRelativeDateTimeFormatter {}
);
#[cfg(feature = "NSFormatter")]
impl NSRelativeDateTimeFormatter {
extern_methods!(
#[unsafe(method(dateTimeStyle))]
#[unsafe(method_family = none)]
pub fn dateTimeStyle(&self) -> NSRelativeDateTimeFormatterStyle;
/// Setter for [`dateTimeStyle`][Self::dateTimeStyle].
#[unsafe(method(setDateTimeStyle:))]
#[unsafe(method_family = none)]
pub fn setDateTimeStyle(&self, date_time_style: NSRelativeDateTimeFormatterStyle);
#[unsafe(method(unitsStyle))]
#[unsafe(method_family = none)]
pub fn unitsStyle(&self) -> NSRelativeDateTimeFormatterUnitsStyle;
/// Setter for [`unitsStyle`][Self::unitsStyle].
#[unsafe(method(setUnitsStyle:))]
#[unsafe(method_family = none)]
pub fn setUnitsStyle(&self, units_style: NSRelativeDateTimeFormatterUnitsStyle);
#[unsafe(method(formattingContext))]
#[unsafe(method_family = none)]
pub fn formattingContext(&self) -> NSFormattingContext;
/// Setter for [`formattingContext`][Self::formattingContext].
#[unsafe(method(setFormattingContext:))]
#[unsafe(method_family = none)]
pub fn setFormattingContext(&self, formatting_context: NSFormattingContext);
#[cfg(feature = "NSCalendar")]
#[unsafe(method(calendar))]
#[unsafe(method_family = none)]
pub fn calendar(&self) -> Retained<NSCalendar>;
#[cfg(feature = "NSCalendar")]
/// Setter for [`calendar`][Self::calendar].
///
/// This is [copied][crate::NSCopying::copy] when set.
#[unsafe(method(setCalendar:))]
#[unsafe(method_family = none)]
pub fn setCalendar(&self, calendar: Option<&NSCalendar>);
#[cfg(feature = "NSLocale")]
#[unsafe(method(locale))]
#[unsafe(method_family = none)]
pub fn locale(&self) -> Retained<NSLocale>;
#[cfg(feature = "NSLocale")]
/// Setter for [`locale`][Self::locale].
///
/// This is [copied][crate::NSCopying::copy] when set.
#[unsafe(method(setLocale:))]
#[unsafe(method_family = none)]
pub fn setLocale(&self, locale: Option<&NSLocale>);
#[cfg(all(feature = "NSCalendar", feature = "NSString"))]
#[unsafe(method(localizedStringFromDateComponents:))]
#[unsafe(method_family = none)]
pub fn localizedStringFromDateComponents(
&self,
date_components: &NSDateComponents,
) -> Retained<NSString>;
#[cfg(all(feature = "NSDate", feature = "NSString"))]
#[unsafe(method(localizedStringFromTimeInterval:))]
#[unsafe(method_family = none)]
pub fn localizedStringFromTimeInterval(
&self,
time_interval: NSTimeInterval,
) -> Retained<NSString>;
#[cfg(all(feature = "NSDate", feature = "NSString"))]
#[unsafe(method(localizedStringForDate:relativeToDate:))]
#[unsafe(method_family = none)]
pub fn localizedStringForDate_relativeToDate(
&self,
date: &NSDate,
reference_date: &NSDate,
) -> Retained<NSString>;
#[cfg(feature = "NSString")]
/// # Safety
///
/// `obj` should be of the correct type.
#[unsafe(method(stringForObjectValue:))]
#[unsafe(method_family = none)]
pub unsafe fn stringForObjectValue(
&self,
obj: Option<&AnyObject>,
) -> Option<Retained<NSString>>;
);
}
/// Methods declared on superclass `NSObject`.
#[cfg(feature = "NSFormatter")]
impl NSRelativeDateTimeFormatter {
extern_methods!(
#[unsafe(method(init))]
#[unsafe(method_family = init)]
pub fn init(this: Allocated<Self>) -> Retained<Self>;
#[unsafe(method(new))]
#[unsafe(method_family = new)]
pub fn new() -> Retained<Self>;
);
}
#[cfg(feature = "NSFormatter")]
impl DefaultRetained for NSRelativeDateTimeFormatter {
#[inline]
fn default_retained() -> Retained<Self> {
Self::new()
}
}