Struct CFString

Source
#[repr(C)]
pub struct CFString(/* private fields */);
Expand description

A reference to a CFString object.

Implementations§

Source§

impl CFString

Source

pub fn with_str(s: &str) -> Self

Creates a new CFStringRef

Source

pub fn iter(&self) -> Iter<'_>

Creates an iterator.

Source

pub unsafe fn create_array_by_separating_strings( alloc: CFAllocatorRef, string: CFStringRef, separator: CFStringRef, ) -> CFArray

Creates an array of CFString objects from a single CFString object.

§Safety

This function dereferences a raw pointer

Source

pub unsafe fn create_by_combining_strings( alloc: CFAllocatorRef, array: CFArrayRef, separator: CFStringRef, ) -> CFString

Creates a single string from the individual CFString objects that comprise the elements of an array.

§Safety

This function dereferences a raw pointer

Source

pub unsafe fn create_copy( alloc: CFAllocatorRef, string: CFStringRef, ) -> CFString

Creates an immutable copy of a string.

§Safety

This function dereferences a raw pointer

Source

pub unsafe fn create_from_external_representation( alloc: CFAllocatorRef, data: CFDataRef, encoding: CFStringEncoding, ) -> CFString

Creates a string from its “external representation.”

§Safety

This function dereferences a raw pointer

Source

pub unsafe fn create_with_bytes( alloc: CFAllocatorRef, bytes: *const UInt8, num_bytes: CFIndex, encoding: CFStringEncoding, is_external_representation: bool, ) -> Self

Creates a string from a buffer containing characters in a specified encoding.

§Safety

This function dereferences a raw pointer

Source

pub unsafe fn create_with_bytes_no_copy( alloc: CFAllocatorRef, bytes: *const UInt8, num_bytes: CFIndex, encoding: CFStringEncoding, is_external_representation: Boolean, contents_deallocator: CFAllocatorRef, ) -> CFString

Creates a string from a buffer, containing characters in a specified encoding, that might serve as the backing store for the new string.

§Safety

This function dereferences a raw pointer

Source

pub unsafe fn create_with_characters( alloc: CFAllocatorRef, chars: *const UniChar, num_chars: CFIndex, ) -> CFString

Creates a string from a buffer of Unicode characters.

§Safety

This function dereferences a raw pointer

Source

pub unsafe fn create_with_characters_no_copy( alloc: CFAllocatorRef, chars: *const UniChar, num_chars: CFIndex, contents_deallocator: CFAllocatorRef, ) -> CFString

Creates a string from a buffer of Unicode characters that might serve as the backing store for the object.

§Safety

This function dereferences a raw pointer

Source

pub unsafe fn create_with_c_string( alloc: CFAllocatorRef, c_str: *const c_char, encoding: CFStringEncoding, ) -> CFString

Creates an immutable string from a C string.

§Safety

This function dereferences a raw pointer

Source

pub unsafe fn create_with_c_string_no_copy( alloc: CFAllocatorRef, c_str: *const c_char, encoding: CFStringEncoding, contents_deallocator: CFAllocatorRef, ) -> CFString

Creates a CFString object from an external C string buffer that might serve as the backing store for the object.

§Safety

This function dereferences a raw pointer

Source

pub unsafe fn create_with_format_and_arguments( alloc: CFAllocatorRef, format_options: CFDictionaryRef, format: CFStringRef, va_list: VaList, ) -> CFString

Creates an immutable string from a formatted string and a variable number of arguments (specified in a parameter of type va_list).

§Safety

This function dereferences a raw pointer

Source

pub unsafe fn create_with_pascal_string( alloc: CFAllocatorRef, p_str: ConstStr255Param, encoding: CFStringEncoding, ) -> CFString

Creates an immutable CFString object from a Pascal string.

§Safety

This function dereferences a raw pointer

Source

pub unsafe fn create_with_pascal_string_no_copy( alloc: CFAllocatorRef, p_str: ConstStr255Param, encoding: CFStringEncoding, contents_deallocator: CFAllocatorRef, ) -> CFString

Creates a CFString object from an external Pascal string buffer that might serve as the backing store for the object.

§Safety

This function dereferences a raw pointer

Source

pub unsafe fn create_with_substring( alloc: CFAllocatorRef, s: CFStringRef, range: CFRange, ) -> CFString

Creates an immutable string from a segment (substring) of an existing string.

§Safety

This function dereferences a raw pointer

Source

pub unsafe fn create_array_with_find_results( alloc: CFAllocatorRef, string: CFStringRef, string_to_find: CFStringRef, range_to_search: CFRange, compare_options: CFStringCompareFlags, ) -> CFArray

Searches a string for multiple occurrences of a substring and creates an array of ranges identifying the locations of these substrings within the target string.

§Safety

This function dereferences a raw pointer

Source

pub unsafe fn find( string: CFStringRef, string_to_find: CFStringRef, compare_options: CFStringCompareFlags, ) -> CFRange

Searches for a substring within a string and, if it is found, yields the range of the substring within the object’s characters.

§Safety

This function dereferences a raw pointer

Source

pub unsafe fn find_character_from_set( string: CFStringRef, set: CFCharacterSetRef, range_to_search: CFRange, search_options: CFStringCompareFlags, result: *mut CFRange, ) -> bool

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

§Safety

This function dereferences a raw pointer

Source

pub unsafe fn find_with_options( string: CFStringRef, string_to_find: CFStringRef, range_to_search: CFRange, search_options: CFStringCompareFlags, result: *mut CFRange, ) -> bool

Searches for a substring within a range of the characters represented by a string and, if the substring is found, returns its range within the object’s characters.

§Safety

This function dereferences a raw pointer

Source

pub unsafe fn find_with_options_and_locale( string: CFStringRef, string_to_find: CFStringRef, range_to_search: CFRange, search_options: CFStringCompareFlags, locale: CFLocaleRef, result: *mut CFRange, ) -> bool

Returns a Boolean value that indicates whether a given string was found in a given source string.

§Safety

This function dereferences a raw pointer

Source

pub unsafe fn get_line_bounds( string: CFStringRef, range: CFRange, line_begin_index: *mut CFIndex, line_end_index: *mut CFIndex, contents_end_index: *mut CFIndex, )

Given a range of characters in a string, obtains the line bounds—that is, the indexes of the first character and the final characters of the lines containing the range.

§Safety

This function dereferences a raw pointer

Source

pub unsafe fn compare( string1: CFStringRef, string2: CFStringRef, compare_options: CFStringCompareFlags, ) -> CFComparisonResult

Compares one string with another string.

§Safety

This function dereferences a raw pointer

Source

pub unsafe fn compare_with_options( string1: CFStringRef, string2: CFStringRef, range_to_compare: CFRange, compare_options: CFStringCompareFlags, ) -> CFComparisonResult

Compares a range of the characters in one string with that of another string.

§Safety

This function dereferences a raw pointer

Source

pub unsafe fn compare_with_options_and_locale( string1: CFStringRef, string2: CFStringRef, range_to_compare: CFRange, compare_options: CFStringCompareFlags, locale: CFLocaleRef, ) -> CFComparisonResult

Compares a range of the characters in one string with another string using a given locale.

§Safety

This function dereferences a raw pointer

Source

pub unsafe fn has_prefix(string: CFStringRef, prefix: CFStringRef) -> bool

Determines if the character data of a string begin with a specified sequence of characters.

§Safety

This function dereferences a raw pointer

Source

pub unsafe fn has_suffix(string: CFStringRef, suffix: CFStringRef) -> bool

Determines if a string ends with a specified sequence of characters.

§Safety

This function dereferences a raw pointer

Source

pub unsafe fn create_external_representation( alloc: CFStringRef, string: CFStringEncoding, encoding: CFStringEncoding, loss_byte: UInt8, ) -> CFData

Creates an “external representation” of a CFString object, that is, a CFData object.

§Safety

This function dereferences a raw pointer

Source

pub unsafe fn get_bytes( string: CFStringRef, range: CFRange, encoding: CFStringEncoding, loss_byte: UInt8, is_external_representation: Boolean, buffer: *mut UInt8, max_buf_len: CFIndex, used_buf_len: *mut CFIndex, ) -> CFIndex

Fetches a range of the characters from a string into a byte buffer after converting the characters to a specified encoding.

§Safety

This function dereferences a raw pointer

Source

pub unsafe fn get_character_at_index( string: CFStringRef, idx: CFIndex, ) -> UniChar

Returns the Unicode character at a specified location in a string.

§Safety

This function dereferences a raw pointer

Source

pub unsafe fn get_characters( string: CFStringRef, range: CFRange, buffer: &mut [UniChar], )

Copies a range of the Unicode characters from a string to a user-provided buffer.

§Safety

This function dereferences a raw pointer

Source

pub unsafe fn get_characters_ptr(string: CFStringRef) -> *const UniChar

Quickly obtains a pointer to the contents of a string as a buffer of Unicode characters.

§Safety

This function dereferences a raw pointer

Source

pub unsafe fn get_character_from_inline_buffer( buf: *mut CFStringInlineBuffer, idx: CFIndex, ) -> UniChar

Returns the Unicode character at a specific location in an in-line buffer.

§Safety

This function dereferences a raw pointer

Source

pub unsafe fn get_c_string( string: CFStringRef, buffer: &mut [c_char], buffer_size: CFIndex, encoding: CFStringEncoding, ) -> bool

Copies the character contents of a string to a local C string buffer after converting the characters to a given encoding.

§Safety

This function dereferences a raw pointer

Source

pub unsafe fn get_c_string_ptr( string: CFStringRef, encoding: CFStringEncoding, ) -> *const c_char

Quickly obtains a pointer to a C-string buffer containing the characters of a string in a given encoding.

§Safety

This function dereferences a raw pointer

Source

pub unsafe fn get_length(string: CFStringRef) -> CFIndex

Returns the number (in terms of UTF-16 code pairs) of Unicode characters in a string.

§Safety

This function dereferences a raw pointer

Source

pub unsafe fn get_pascal_string( string: CFStringRef, buffer: StringPtr, buffer_size: CFIndex, encoding: CFStringEncoding, ) -> bool

Copies the character contents of a CFString object to a local Pascal string buffer after converting the characters to a requested encoding.

§Safety

This function dereferences a raw pointer

Source

pub unsafe fn get_pascal_string_ptr( string: CFStringRef, encoding: CFStringEncoding, ) -> ConstStr255Param

Quickly obtains a pointer to a Pascal buffer containing the characters of a string in a given encoding.

§Safety

This function dereferences a raw pointer

Source

pub unsafe fn get_range_of_composed_characters_at_index( string: CFStringRef, index: CFIndex, ) -> CFRange

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

§Safety

This function dereferences a raw pointer

Source

pub unsafe fn init_inline_buffer( s: CFStringRef, buf: *mut CFStringInlineBuffer, range: CFRange, )

Initializes an in-line buffer to use for efficient access of a CFString object’s characters.

§Safety

This function dereferences a raw pointer

Source

pub unsafe fn get_hyphenation_location_before_index( string: CFStringRef, location: CFIndex, limit_range: CFRange, options: CFOptionFlags, locale: CFLocaleRef, character: *mut UTF32Char, ) -> CFIndex

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

§Safety

This function dereferences a raw pointer

Source

pub unsafe fn is_hyphenation_available_for_locale( locale: CFLocaleRef, ) -> Boolean

Returns a Boolean value that indicates whether hyphenation data is available.

§Safety

This function dereferences a raw pointer

Source

pub unsafe fn convert_encoding_to_ianachar_set_name( encoding: CFStringEncoding, ) -> CFString

Returns the name of the IANA registry “charset” that is the closest mapping to a specified string encoding.

§Safety

This function dereferences a raw pointer

Source

pub unsafe fn convert_encoding_to_nsstring_encoding( encoding: CFStringEncoding, ) -> c_ulong

Returns the Cocoa encoding constant that maps most closely to a given Core Foundation encoding constant.

§Safety

This function dereferences a raw pointer

Source

pub unsafe fn convert_encoding_to_windows_codepage( encoding: CFStringEncoding, ) -> UInt32

Returns the Windows codepage identifier that maps most closely to a given Core Foundation encoding constant.

§Safety

This function dereferences a raw pointer

Source

pub unsafe fn convert_iana_char_set_name_to_encodingng( string: CFStringRef, ) -> CFStringEncoding

Returns the Core Foundation encoding constant that is the closest mapping to a given IANA registry “charset” name.

§Safety

This function dereferences a raw pointer

Source

pub unsafe fn convert_nsstring_encoding_to_encodingng( encoding: c_ulong, ) -> CFStringEncoding

Returns the Core Foundation encoding constant that is the closest mapping to a given Cocoa encoding.

§Safety

This function dereferences a raw pointer

Source

pub unsafe fn convert_windows_codepage_to_encoding( codepage: UInt32, ) -> CFStringEncoding

Returns the Core Foundation encoding constant that is the closest mapping to a given Windows codepage identifier.

§Safety

This function dereferences a raw pointer

Source

pub unsafe fn get_fastest_encoding(string: CFStringRef) -> CFStringEncoding

Returns for a CFString object the character encoding that requires the least conversion time.

§Safety

This function dereferences a raw pointer

Source

pub unsafe fn get_list_of_available_encodings() -> *const CFStringEncoding

Returns a pointer to a list of string encodings supported by the current system.

§Safety

This function dereferences a raw pointer

Source

pub unsafe fn get_maximum_size_for_encoding( length: CFIndex, encoding: CFStringEncoding, ) -> CFIndex

Returns the maximum number of bytes a string of a specified length (in Unicode characters) will take up if encoded in a specified encoding.

§Safety

This function dereferences a raw pointer

Source

pub unsafe fn get_most_compatible_mac_string_encoding( encoding: CFStringEncoding, ) -> CFStringEncoding

Returns the most compatible Mac OS script value for the given input encoding.

§Safety

This function dereferences a raw pointer

Source

pub unsafe fn get_name_of_encoding(encoding: CFStringEncoding) -> CFString

Returns the canonical name of a specified string encoding.

§Safety

This function dereferences a raw pointer

Source

pub unsafe fn get_smallest_encoding(string: CFStringRef) -> CFStringEncoding

Returns the smallest encoding on the current system for the character contents of a string.

§Safety

This function dereferences a raw pointer

Source

pub unsafe fn get_system_encoding() -> CFStringEncoding

Returns the default encoding used by the operating system when it creates strings.

§Safety

This function dereferences a raw pointer

Source

pub unsafe fn is_encoding_available(encoding: CFStringEncoding) -> bool

Determines whether a given Core Foundation string encoding is available on the current system.

§Safety

This function dereferences a raw pointer

Source

pub unsafe fn get_double_value(s: CFStringRef) -> c_double

Returns the primary c_double value represented by a string.

§Safety

This function dereferences a raw pointer

Source

pub unsafe fn get_int_value(s: CFStringRef) -> SInt32

Returns the SInt32 value represented by a string.

§Safety

This function dereferences a raw pointer

Source

pub unsafe fn cf_show_str(s: CFStringRef)

Prints the attributes of a string during debugging.

§Safety

This function dereferences a raw pointer

Source

pub unsafe fn get_type_id() -> CFTypeID

Returns the type identifier for the CFString opaque type.

§Safety

This function dereferences a raw pointer

Source

pub unsafe fn create_with_file_system_representation( alloc: CFAllocatorRef, buffer: *const c_char, ) -> CFString

Creates a CFString from a zero-terminated POSIX file system representation.

§Safety

This function dereferences a raw pointer

Source

pub unsafe fn get_file_system_representation( string: CFStringRef, buffer: &mut [c_char], max_buf_len: CFIndex, ) -> Boolean

Extracts the contents of a string as a NULL-terminated 8-bit string appropriate for passing to POSIX APIs.

§Safety

This function dereferences a raw pointer

Source

pub unsafe fn get_maximum_size_of_file_system_representation( string: CFStringRef, ) -> CFIndex

Determines the upper bound on the number of bytes required to hold the file system representation of the string.

§Safety

This function dereferences a raw pointer

Source

pub unsafe fn get_paragraph_bounds( string: CFStringRef, range: CFRange, par_begin_index: *mut CFIndex, par_end_index: *mut CFIndex, contents_end_index: *mut CFIndex, )

Determines the upper bound on the number of bytes required to hold the file system representation of the string.

§Safety

This function dereferences a raw pointer

Source

pub unsafe fn get_long_character_for_surrogate_pair( surrogate_high: UniChar, surrogate_low: UniChar, ) -> UTF32Char

Returns a UTF-32 character that corresponds to a given pair of UTF-16 surrogate characters.

§Safety

This function dereferences a raw pointer

Source

pub unsafe fn get_surrogate_pair_for_long_character( character: UTF32Char, surrogates: &mut [UniChar], ) -> Boolean

Maps a given UTF-32 character to a pair of UTF-16 surrogate characters.

§Safety

This function dereferences a raw pointer

Source

pub unsafe fn is_surrogate_high_character(character: UniChar) -> Boolean

Returns a Boolean value that indicates whether a given character is a high character in a surrogate pair.

§Safety

This function dereferences a raw pointer

Source

pub unsafe fn is_surrogate_low_character(character: UniChar) -> Boolean

Returns a Boolean value that indicates whether a given character is a low character in a surrogate pair.

§Safety

This function dereferences a raw pointer

Trait Implementations§

Source§

impl CFTypeObject for CFString

Source§

type Ref = *const __CFString

Source§

fn get_internal_object(&self) -> Self::Ref

Retrieves the internal object
Source§

fn create_with_ref(obj: Self::Ref) -> Self

Source§

impl Debug for CFString

Source§

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

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

impl Display for CFString

Source§

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

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

impl Drop for CFString

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

impl<'a> From<&'a CFString> for Cow<'a, str>

Source§

fn from(cf_str: &'a CFString) -> Cow<'a, str>

Converts to this type from the input type.
Source§

impl<'a> IntoIterator for &'a CFString

Source§

type Item = u16

The type of the elements being iterated over.
Source§

type IntoIter = Iter<'a>

Which kind of iterator are we turning this into?
Source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
Source§

impl PartialEq<&str> for CFString

Source§

fn eq(&self, other: &&str) -> 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 PartialEq for CFString

Source§

fn eq(&self, other: &Self) -> 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 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<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.