CFString

Struct CFString 

Source
pub struct CFString { /* private fields */ }
Expand description

Apple’s documentation

This is toll-free bridged with NSString.

Implementations§

Source§

impl CFString

Source

pub unsafe fn with_pascal_string( alloc: Option<&CFAllocator>, p_str: *const i8, encoding: u32, ) -> Option<CFRetained<CFString>>

  • Immutable string creation functions **
§Safety
  • alloc might not allow None.
  • p_str must be a valid pointer.
Source

pub unsafe fn with_c_string( alloc: Option<&CFAllocator>, c_str: *const i8, encoding: u32, ) -> Option<CFRetained<CFString>>

§Safety
  • alloc might not allow None.
  • c_str must be a valid pointer.
Source

pub unsafe fn with_bytes( alloc: Option<&CFAllocator>, bytes: *const u8, num_bytes: isize, encoding: u32, is_external_representation: bool, ) -> Option<CFRetained<CFString>>

§Safety
  • alloc might not allow None.
  • bytes must be a valid pointer.
Source

pub unsafe fn with_characters( alloc: Option<&CFAllocator>, chars: *const u16, num_chars: isize, ) -> Option<CFRetained<CFString>>

§Safety
  • alloc might not allow None.
  • chars must be a valid pointer.
Source

pub unsafe fn with_pascal_string_no_copy( alloc: Option<&CFAllocator>, p_str: *const i8, encoding: u32, contents_deallocator: Option<&CFAllocator>, ) -> Option<CFRetained<CFString>>

§Safety
  • alloc might not allow None.
  • p_str must be a valid pointer.
  • contents_deallocator might not allow None.
Source

pub unsafe fn with_c_string_no_copy( alloc: Option<&CFAllocator>, c_str: *const i8, encoding: u32, contents_deallocator: Option<&CFAllocator>, ) -> Option<CFRetained<CFString>>

§Safety
  • alloc might not allow None.
  • c_str must be a valid pointer.
  • contents_deallocator might not allow None.
Source

pub unsafe fn with_bytes_no_copy( alloc: Option<&CFAllocator>, bytes: *const u8, num_bytes: isize, encoding: u32, is_external_representation: bool, contents_deallocator: Option<&CFAllocator>, ) -> Option<CFRetained<CFString>>

§Safety
  • alloc might not allow None.
  • bytes must be a valid pointer.
  • contents_deallocator might not allow None.
Source

pub unsafe fn with_characters_no_copy( alloc: Option<&CFAllocator>, chars: *const u16, num_chars: isize, contents_deallocator: Option<&CFAllocator>, ) -> Option<CFRetained<CFString>>

§Safety
  • alloc might not allow None.
  • chars must be a valid pointer.
  • contents_deallocator might not allow None.
Source

pub unsafe fn with_substring( alloc: Option<&CFAllocator>, str: Option<&CFString>, range: CFRange, ) -> Option<CFRetained<CFString>>

§Safety
  • alloc might not allow None.
  • str might not allow None.
Source

pub fn new_copy( alloc: Option<&CFAllocator>, the_string: Option<&CFString>, ) -> Option<CFRetained<CFString>>

Source§

impl CFString

Source

pub fn length(&self) -> isize

  • Basic accessors for the contents **
Source

pub unsafe fn character_at_index(&self, idx: isize) -> u16

Source

pub unsafe fn characters(&self, range: CFRange, buffer: *mut u16)

§Safety

buffer must be a valid pointer.

Source

pub unsafe fn pascal_string( &self, buffer: *mut i8, buffer_size: isize, encoding: u32, ) -> bool

§Safety

buffer must be a valid pointer.

Source

pub unsafe fn c_string( &self, buffer: *mut i8, buffer_size: isize, encoding: u32, ) -> bool

§Safety

buffer must be a valid pointer.

Source

pub fn pascal_string_ptr(&self, encoding: u32) -> *const i8

Source

pub fn c_string_ptr(&self, encoding: u32) -> *const i8

Source

pub fn characters_ptr(&self) -> *const u16

Source

pub unsafe fn bytes( &self, range: CFRange, encoding: u32, loss_byte: u8, is_external_representation: bool, buffer: *mut u8, max_buf_len: isize, used_buf_len: *mut isize, ) -> isize

§Safety
  • buffer must be a valid pointer.
  • used_buf_len must be a valid pointer.
Source

pub fn from_external_representation( alloc: Option<&CFAllocator>, data: Option<&CFData>, encoding: u32, ) -> Option<CFRetained<CFString>>

Source

pub fn new_external_representation( alloc: Option<&CFAllocator>, the_string: Option<&CFString>, encoding: u32, loss_byte: u8, ) -> Option<CFRetained<CFData>>

Source

pub fn smallest_encoding(&self) -> u32

Source

pub fn fastest_encoding(&self) -> u32

Source

pub fn system_encoding() -> u32

Source

pub fn maximum_size_for_encoding(length: isize, encoding: u32) -> isize

Source

pub unsafe fn file_system_representation( &self, buffer: *mut i8, max_buf_len: isize, ) -> bool

  • FileSystem path conversion functions **
§Safety

buffer must be a valid pointer.

Source

pub fn maximum_size_of_file_system_representation(&self) -> isize

Source

pub unsafe fn with_file_system_representation( alloc: Option<&CFAllocator>, buffer: *const i8, ) -> Option<CFRetained<CFString>>

§Safety
  • alloc might not allow None.
  • buffer must be a valid pointer.
Source§

impl CFString

Source

pub unsafe fn compare_with_options_and_locale( &self, the_string2: Option<&CFString>, range_to_compare: CFRange, compare_options: CFStringCompareFlags, locale: Option<&CFLocale>, ) -> CFComparisonResult

§Safety
  • the_string2 might not allow None.
  • locale might not allow None.
Source

pub unsafe fn compare_with_options( &self, the_string2: Option<&CFString>, range_to_compare: CFRange, compare_options: CFStringCompareFlags, ) -> CFComparisonResult

§Safety

the_string2 might not allow None.

Source

pub fn compare( &self, the_string2: Option<&CFString>, compare_options: CFStringCompareFlags, ) -> CFComparisonResult

Source

pub unsafe fn find_with_options_and_locale( &self, string_to_find: Option<&CFString>, range_to_search: CFRange, search_options: CFStringCompareFlags, locale: Option<&CFLocale>, result: *mut CFRange, ) -> bool

§Safety
  • string_to_find might not allow None.
  • locale might not allow None.
  • result must be a valid pointer.
Source

pub unsafe fn find_with_options( &self, string_to_find: Option<&CFString>, range_to_search: CFRange, search_options: CFStringCompareFlags, result: *mut CFRange, ) -> bool

§Safety
  • string_to_find might not allow None.
  • result must be a valid pointer.
Source

pub unsafe fn new_array_with_find_results( alloc: Option<&CFAllocator>, the_string: Option<&CFString>, string_to_find: Option<&CFString>, range_to_search: CFRange, compare_options: CFStringCompareFlags, ) -> Option<CFRetained<CFArray>>

§Safety
  • alloc might not allow None.
  • the_string might not allow None.
  • string_to_find might not allow None.
Source

pub fn find( &self, string_to_find: Option<&CFString>, compare_options: CFStringCompareFlags, ) -> CFRange

Source

pub fn has_prefix(&self, prefix: Option<&CFString>) -> bool

Source

pub fn has_suffix(&self, suffix: Option<&CFString>) -> bool

Source

pub unsafe fn range_of_composed_characters_at_index( &self, the_index: isize, ) -> CFRange

Returns the range of the composed character sequence at the specified index.

Parameter theString: The CFString which is to be searched. If this parameter is not a valid CFString, the behavior is undefined.

Parameter theIndex: The index of the character contained in the composed character sequence. If the index is outside the index space of the string (0 to N-1 inclusive, where N is the length of the string), the behavior is undefined.

Returns: The range of the composed character sequence.

Source

pub unsafe fn find_character_from_set( &self, the_set: Option<&CFCharacterSet>, range_to_search: CFRange, search_options: CFStringCompareFlags, result: *mut CFRange, ) -> bool

Query the range of the first character contained in the specified character set.

Parameter theString: The CFString which is to be searched. If this parameter is not a valid CFString, the behavior is undefined.

Parameter theSet: The CFCharacterSet against which the membership of characters is checked. If this parameter is not a valid CFCharacterSet, the behavior is undefined.

Parameter rangeToSearch: The range of characters within the string to search. If the range location or end point (defined by the location plus length minus 1) are outside the index space of the string (0 to N-1 inclusive, where N is the length of the string), the behavior is undefined. If the range length is negative, the behavior is undefined. The range may be empty (length 0), in which case no search is performed.

Parameter searchOptions: The bitwise-or’ed option flags to control the search behavior. The supported options are kCFCompareBackwards andkCFCompareAnchored. If other option flags are specified, the behavior is undefined.

Parameter result: The pointer to a CFRange supplied by the caller in which the search result is stored. Note that the length of this range can be more than 1, if for instance the result is a composed character. If a pointer to an invalid memory is specified, the behavior is undefined.

Returns: true, if at least a character which is a member of the character set is found and result is filled, otherwise, false.

§Safety
  • the_set might not allow None.
  • result must be a valid pointer.
Source

pub unsafe fn line_bounds( &self, range: CFRange, line_begin_index: *mut isize, line_end_index: *mut isize, contents_end_index: *mut isize, )

§Safety
  • line_begin_index must be a valid pointer.
  • line_end_index must be a valid pointer.
  • contents_end_index must be a valid pointer.
Source

pub unsafe fn paragraph_bounds( &self, range: CFRange, par_begin_index: *mut isize, par_end_index: *mut isize, contents_end_index: *mut isize, )

§Safety
  • par_begin_index must be a valid pointer.
  • par_end_index must be a valid pointer.
  • contents_end_index must be a valid pointer.
Source

pub unsafe fn hyphenation_location_before_index( &self, location: isize, limit_range: CFRange, options: usize, locale: Option<&CFLocale>, character: *mut u32, ) -> isize

Retrieve the first potential hyphenation location found before the specified location.

Parameter string: The CFString which is to be hyphenated. If this parameter is not a valid CFString, the behavior is undefined.

Parameter location: An index in the string. If a valid hyphen index is returned, it will be before this index.

Parameter limitRange: The range of characters within the string to search. If the range location or end point (defined by the location plus length minus 1) are outside the index space of the string (0 to N-1 inclusive, where N is the length of the string), the behavior is undefined. If the range length is negative, the behavior is undefined. The range may be empty (length 0), in which case no hyphen location is generated.

Parameter options: Reserved for future use.

Parameter locale: Specifies which language’s hyphenation conventions to use. This must be a valid locale. Hyphenation data is not available for all locales. You can use CFStringIsHyphenationAvailableForLocale to test for availability of hyphenation data.

Parameter character: The suggested hyphen character to insert. Pass NULL if you do not need this information.

Returns: an index in the string where it is appropriate to insert a hyphen, if one exists; else kCFNotFound

§Safety
  • locale might not allow None.
  • character must be a valid pointer.
Source

pub fn is_hyphenation_available_for_locale(locale: Option<&CFLocale>) -> bool

Source

pub unsafe fn new_by_combining_strings( alloc: Option<&CFAllocator>, the_array: Option<&CFArray>, separator_string: Option<&CFString>, ) -> Option<CFRetained<CFString>>

  • Exploding and joining strings with a separator string **
§Safety
  • alloc might not allow None.
  • the_array generic must be of the correct type.
  • the_array might not allow None.
  • separator_string might not allow None.
Source

pub fn new_array_by_separating_strings( alloc: Option<&CFAllocator>, the_string: Option<&CFString>, separator_string: Option<&CFString>, ) -> Option<CFRetained<CFArray>>

Source

pub fn int_value(&self) -> i32

  • Parsing non-localized numbers from strings **
Source

pub fn double_value(&self) -> f64

Source§

impl CFString

Source§

impl CFString

Source

pub fn from_str(string: &str) -> CFRetained<CFString>

Creates a new CFString from a str.

Source

pub fn new(string: &str) -> CFRetained<CFString>

👎Deprecated: renamed to CFString::from_str

Alias for easier transition from the core-foundation crate.

Source

pub fn from_static_str(string: &'static str) -> CFRetained<CFString>

Creates a new CFString from a 'static str.

This may be slightly more efficient than CFString::from_str, as it may be able to re-use the existing buffer (since we know it won’t be deallocated).

Source

pub unsafe fn as_str_unchecked(&self) -> Option<&str>

Get the str representation of this string if it can be done efficiently.

Returns None if the internal storage does not allow this to be done efficiently. Use CFString::to_string if performance is not an issue.

§Safety

The CFString must not be mutated for the lifetime of the returned string.

Warning: This is very difficult to ensure in generic contexts, e.g. it cannot even be used inside Debug::fmt, since Formatter uses dyn internally, and could thus mutate the string inside there.

Methods from Deref<Target = CFType>§

Source

pub fn downcast_ref<T>(&self) -> Option<&T>
where T: ConcreteType,

Attempt to downcast the type to that of type T.

This is the reference-variant. Use CFRetained::downcast if you want to convert a retained type. See also ConcreteType for more details on which types support being converted to.

Source

pub fn retain_count(&self) -> usize

Get the reference count of the object.

This function may be useful for debugging. You normally do not use this function otherwise.

Beware that some things (like CFNumbers, small CFStrings etc.) may not have a normal retain count for optimization purposes, and can return usize::MAX in that case.

Trait Implementations§

Source§

impl AsRef<AnyObject> for CFString

Source§

fn as_ref(&self) -> &AnyObject

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl AsRef<CFString> for CFString

Source§

fn as_ref(&self) -> &CFString

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl AsRef<CFString> for NSString

Available on crate feature objc2-core-foundation only.
Source§

fn as_ref(&self) -> &CFString

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl AsRef<CFType> for CFString

Source§

fn as_ref(&self) -> &CFType

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl AsRef<NSString> for CFString

Available on crate feature objc2-core-foundation only.
Source§

fn as_ref(&self) -> &NSString

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl Borrow<AnyObject> for CFString

Source§

fn borrow(&self) -> &AnyObject

Immutably borrows from an owned value. Read more
Source§

impl Borrow<CFType> for CFString

Source§

fn borrow(&self) -> &CFType

Immutably borrows from an owned value. Read more
Source§

impl ConcreteType for CFString

Source§

fn type_id() -> usize

Get the unique CFTypeID identifier for the type. Read more
Source§

impl Debug for CFString

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl Deref for CFString

Source§

type Target = CFType

The resulting type after dereferencing.
Source§

fn deref(&self) -> &<CFString as Deref>::Target

Dereferences the value.
Source§

impl Display for CFString

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl Hash for CFString

Source§

fn hash<H>(&self, state: &mut H)
where H: Hasher,

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl Message for CFString

Source§

fn retain(&self) -> Retained<Self>
where Self: Sized,

Increment the reference count of the receiver. Read more
Source§

impl Ord for CFString

Source§

fn cmp(&self, other: &CFString) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

impl PartialEq for CFString

Source§

fn eq(&self, other: &CFString) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialOrd for CFString

Source§

fn partial_cmp(&self, other: &CFString) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl RefEncode for CFString

Source§

const ENCODING_REF: Encoding

The Objective-C type-encoding for a reference of this type. Read more
Source§

impl Type for CFString

Source§

fn retain(&self) -> CFRetained<Self>
where Self: Sized,

Increment the reference count of the receiver. Read more
Source§

fn as_concrete_TypeRef(&self) -> &Self

👎Deprecated: this is redundant
Helper for easier transition from the core-foundation crate.
Source§

unsafe fn wrap_under_get_rule(ptr: *const Self) -> CFRetained<Self>
where Self: Sized,

👎Deprecated: use CFRetained::retain
Helper for easier transition from the core-foundation crate. Read more
Source§

fn as_CFTypeRef(&self) -> &CFType
where Self: AsRef<CFType>,

👎Deprecated: this is redundant (CF types deref to CFType)
Helper for easier transition from the core-foundation crate.
Source§

unsafe fn wrap_under_create_rule(ptr: *const Self) -> CFRetained<Self>
where Self: Sized,

👎Deprecated: use CFRetained::from_raw
Helper for easier transition from the core-foundation crate. Read more
Source§

impl Eq for CFString

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> AutoreleaseSafe for T
where T: ?Sized,