#[repr(C)]pub struct OBEXFileTransferServices { /* private fields */ }OBEXFileTransferServices and objc2 only.Expand description
Implementations§
Source§impl OBEXFileTransferServices
impl OBEXFileTransferServices
pub unsafe fn delegate(&self) -> Option<Retained<AnyObject>>
Sourcepub unsafe fn setDelegate(&self, delegate: Option<&AnyObject>)
pub unsafe fn setDelegate(&self, delegate: Option<&AnyObject>)
Setter for delegate.
Sourcepub unsafe fn withOBEXSession(
in_obex_session: Option<&IOBluetoothOBEXSession>,
) -> Option<Retained<Self>>
Available on crate features IOBluetoothOBEXSession and OBEXSession only.
pub unsafe fn withOBEXSession( in_obex_session: Option<&IOBluetoothOBEXSession>, ) -> Option<Retained<Self>>
IOBluetoothOBEXSession and OBEXSession only.Create a new OBEXFileTransferServices object
This object must be constructed with a valid IOBluetoothOBEXSession. The given IOBluetoothOBEXSession does not need to be connected to the remote server. This module can be manually connected through the connect(void) method.
Parameter inOBEXSession: A valid IOBluetoothOBEXSession
Returns: A newly created OBEXFileTransferServices object on success, nil on failure
Sourcepub unsafe fn initWithOBEXSession(
this: Allocated<Self>,
in_obex_session: Option<&IOBluetoothOBEXSession>,
) -> Option<Retained<Self>>
Available on crate features IOBluetoothOBEXSession and OBEXSession only.
pub unsafe fn initWithOBEXSession( this: Allocated<Self>, in_obex_session: Option<&IOBluetoothOBEXSession>, ) -> Option<Retained<Self>>
IOBluetoothOBEXSession and OBEXSession only.Create a new OBEXFileTransferServices object
This object must be constructed with a valid IOBluetoothOBEXSession. The given IOBluetoothOBEXSession does not need to be connected to the remote server. OBEXFileTransferServices can be manually connected through the provided connection methods.
Parameter inOBEXSession: A valid IOBluetoothOBEXSession
Returns: A newly created OBEXFileTransferServices object on success, nil on failure
Sourcepub unsafe fn currentPath(&self) -> Option<Retained<NSString>>
Available on crate feature objc2-foundation only.
pub unsafe fn currentPath(&self) -> Option<Retained<NSString>>
objc2-foundation only.Get the remote current directory path during an FTP session
This path is changed with each path-specific command called on OBEXFileTransferServices.
Returns: The current path being browsed over FTP
Sourcepub unsafe fn isBusy(&self) -> bool
pub unsafe fn isBusy(&self) -> bool
Get the action state of the module
OBEXFileTransferServices will be considered “busy” when an operation in taking place or has not completed. Calling abort: on this module will not automatically reset its busy state. The user will have to wait for the operation to complete or for the current operation to timeout.
Returns: Success or failure code.
Sourcepub unsafe fn isConnected(&self) -> bool
pub unsafe fn isConnected(&self) -> bool
Get the connected state of this module.
Asks the OBEXSession that was passed to it on creation if it has an open OBEX connection
Returns: Success or failure code.
Sourcepub unsafe fn connectToFTPService(&self) -> OBEXError
Available on crate feature OBEX only.
pub unsafe fn connectToFTPService(&self) -> OBEXError
OBEX only.Connect to a remote device for FTP operations
If the OBEXSession given to OBEXFileTransferServices on creation is not connected it can be manually connected through this method.
Returns: kOBEXSuccess, kOBEXSessionBusyError, or kOBEXSessionAlreadyConnectedError, kOBEXNoResourcesError initially. Further results returned through the fileTransferServicesConnectionComplete: delegate method if initially successful.
Sourcepub unsafe fn connectToObjectPushService(&self) -> OBEXError
Available on crate feature OBEX only.
pub unsafe fn connectToObjectPushService(&self) -> OBEXError
OBEX only.Connect to a remote device for ObjectPush operations. Most of the FTP functionality of this object will be disabled.
If the OBEXSession given to OBEXFileTransferServices on creation is not connected it can be manually connected through this method.
Returns: kOBEXSuccess, kOBEXSessionBusyError, or kOBEXSessionAlreadyConnectedError, kOBEXNoResourcesError initially. Further results returned through the fileTransferServicesConnectionComplete: delegate method if initially successful.
Sourcepub unsafe fn disconnect(&self) -> OBEXError
Available on crate feature OBEX only.
pub unsafe fn disconnect(&self) -> OBEXError
OBEX only.Disconnect from the remote device
The user can manually disconnect the OBEXSession from the remote device if they want to. OBEXFileTransferServices will disconnect the OBEXSession at release only if it was responsible for opening the connection via a connect method.
Returns: kOBEXSuccess, kOBEXSessionNotConnectedError, or kOBEXSessionBusyError initially. Further results returned through the fileTransferServicesDisconnectionComplete: delegate method if initially successful.
Sourcepub unsafe fn changeCurrentFolderToRoot(&self) -> OBEXError
Available on crate feature OBEX only.
pub unsafe fn changeCurrentFolderToRoot(&self) -> OBEXError
OBEX only.Asynchronously change to the remote root directory
Equivalent to ‘cd ~/’
Returns: kOBEXSuccess or kOBEXSessionBusyError initially. Further results returned through the fileTransferServicesPathChangeComplete: delegate method if initially successful.
Sourcepub unsafe fn changeCurrentFolderBackward(&self) -> OBEXError
Available on crate feature OBEX only.
pub unsafe fn changeCurrentFolderBackward(&self) -> OBEXError
OBEX only.Change to the directory above the current level if not at the root
Equivalent to ‘cd ..’ only if remote path is not already at root.
Returns: kOBEXSuccess or kOBEXSessionBusyError initially. Further results returned through the fileTransferServicesPathChangeComplete: delegate method if initially successful.
Sourcepub unsafe fn changeCurrentFolderForwardToPath(
&self,
in_dir_name: Option<&NSString>,
) -> OBEXError
Available on crate features OBEX and objc2-foundation only.
pub unsafe fn changeCurrentFolderForwardToPath( &self, in_dir_name: Option<&NSString>, ) -> OBEXError
OBEX and objc2-foundation only.Change the remote path
Equivalent to ‘cd dirName’.
Parameter inDirName: The name of the remote folder to be set as current
Returns: kOBEXSuccess, kOBEXSessionBusyError, or kOBEXBadArgumentError initially. Further results returned through the fileTransferServicesPathChangeComplete: delegate method if initially successful.
Sourcepub unsafe fn createFolder(&self, in_dir_name: Option<&NSString>) -> OBEXError
Available on crate features OBEX and objc2-foundation only.
pub unsafe fn createFolder(&self, in_dir_name: Option<&NSString>) -> OBEXError
OBEX and objc2-foundation only.Create a folder on the remote target
Equivalent to ‘mkdir dirName’.
Parameter inDirName: The name of the folder to be created
Returns: kOBEXSuccess, kOBEXSessionBusyError, or kOBEXBadArgumentError initially. Further results returned through the fileTransferServicesCreateFolderComplete delegate method if initially successful.
Sourcepub unsafe fn removeItem(&self, in_item_name: Option<&NSString>) -> OBEXError
Available on crate features OBEX and objc2-foundation only.
pub unsafe fn removeItem(&self, in_item_name: Option<&NSString>) -> OBEXError
OBEX and objc2-foundation only.Remove a remote item.
Not supported for use on Apple computer targets
Parameter inItemName: The name of the remote item to be removed
Returns: kOBEXSuccess, kOBEXSessionBusyError, or kOBEXBadArgumentError initially. Further results returned through the fileTransferServicesRemoveItemComplete: delegate method if initially successful.
Sourcepub unsafe fn retrieveFolderListing(&self) -> OBEXError
Available on crate feature OBEX only.
pub unsafe fn retrieveFolderListing(&self) -> OBEXError
OBEX only.Get a remote directory listing
Equivalent to ‘ls’.
Returns: kOBEXSuccess or kOBEXSessionBusyError initially. Further results returned through the fileTransferServicesRetrieveFolderListingComplete: delegate method if initially successful.
Sourcepub unsafe fn sendFile(
&self,
in_local_path_and_name: Option<&NSString>,
) -> OBEXError
Available on crate features OBEX and objc2-foundation only.
pub unsafe fn sendFile( &self, in_local_path_and_name: Option<&NSString>, ) -> OBEXError
OBEX and objc2-foundation only.Put a local file to the remote target
Equivalent to ‘mv inLocalFilePath remoteCurrentPath’.
Parameter inLocalPathAndName: The name and path of the file to be sent an instance of OBEXFilePut.
Returns: kOBEXSuccess, kOBEXSessionBusyError, or kOBEXBadArgumentError initially. Further results returned through the fileTransferServicesSendComplete: and fileTransferServicesSendProgress: delegate methods if initially successful.
Sourcepub unsafe fn copyRemoteFile_toLocalPath(
&self,
in_remote_file_name: Option<&NSString>,
in_local_path_and_name: Option<&NSString>,
) -> OBEXError
Available on crate features OBEX and objc2-foundation only.
pub unsafe fn copyRemoteFile_toLocalPath( &self, in_remote_file_name: Option<&NSString>, in_local_path_and_name: Option<&NSString>, ) -> OBEXError
OBEX and objc2-foundation only.Copy a remote file to a local path
Equivalent to ‘cp remotePath/remoteFileName localPathAndName’.
Parameter inRemoteFileName: The name of the remote file to get
Parameter inLocalPathAndName: The path and name of where the received file will go
Returns: kOBEXSuccess, kOBEXSessionBusyError, or kOBEXBadArgumentError. initially. Further results returned through the fileTransferServicesGetComplete: and fileTransferServicesGetProgress: delegate methods if initially successful.
Sourcepub unsafe fn sendData_type_name(
&self,
in_data: Option<&NSData>,
in_type: Option<&NSString>,
in_name: Option<&NSString>,
) -> OBEXError
Available on crate features OBEX and objc2-foundation only.
pub unsafe fn sendData_type_name( &self, in_data: Option<&NSData>, in_type: Option<&NSString>, in_name: Option<&NSString>, ) -> OBEXError
OBEX and objc2-foundation only.Send data to a remote target
Use this method when you have data to send but no file to read from.
Parameter inData: The data to be sent
Parameter inType: The type of the data to be sent that will be used in the OBEX type header,
usually a mime-type. For example, use “text/x-vCard” when sending vCards. This
argument is optional.
Parameter inName: The name of the file that the data can be referenced as.
Returns: kOBEXSuccess, kOBEXSessionBusyError, or kOBEXBadArgumentError initially. Further results returned through the fileTransferServicesSendComplete: and fileTransferServicesSendProgress: delegate methods if initially successful.
Sourcepub unsafe fn getDefaultVCard(
&self,
in_local_path_and_name: Option<&NSString>,
) -> OBEXError
Available on crate features OBEX and objc2-foundation only.
pub unsafe fn getDefaultVCard( &self, in_local_path_and_name: Option<&NSString>, ) -> OBEXError
OBEX and objc2-foundation only.Get the remote default VCard, if it is supported
Some devices such as cellphones and computers support default VCards
Parameter inLocalPathAndName: The path and name of where the received file will go
Returns: kOBEXSuccess, kOBEXSessionBusyError, or kOBEXBadArgumentError initially. Further results returned through the fileTransferServicesGetComplete: and fileTransferServicesGetProgress: delegate methods if initially successful.
Sourcepub unsafe fn abort(&self) -> OBEXError
Available on crate feature OBEX only.
pub unsafe fn abort(&self) -> OBEXError
OBEX only.Abort the current operation
Attempts send an abort request to the remote device. Returns the OBEXFileTransferServices object to an idle state though the state of the remote device is not guaranteed.
Returns: kOBEXSuccess, or kOBEXGeneralError if no command is in progress. ABORT commands can only be sent on our turn, meaning we may have to timeout if the target side never responds to the command in progress. In that case this object will call back with a status of kOBEXTimeoutError and an error. Further results returned through the fileTransferServicesAbortComplete: delegate method if initially successful.
Methods from Deref<Target = NSObject>§
Sourcepub fn doesNotRecognizeSelector(&self, sel: Sel) -> !
pub fn doesNotRecognizeSelector(&self, sel: Sel) -> !
Handle messages the object doesn’t recognize.
See Apple’s documentation for details.
Methods from Deref<Target = AnyObject>§
Sourcepub fn class(&self) -> &'static AnyClass
pub fn class(&self) -> &'static AnyClass
Dynamically find the class of this object.
§Panics
May panic if the object is invalid (which may be the case for objects
returned from unavailable init/new methods).
§Example
Check that an instance of NSObject has the precise class NSObject.
use objc2::ClassType;
use objc2::runtime::NSObject;
let obj = NSObject::new();
assert_eq!(obj.class(), NSObject::class());Sourcepub unsafe fn get_ivar<T>(&self, name: &str) -> &Twhere
T: Encode,
👎Deprecated: this is difficult to use correctly, use Ivar::load instead.
pub unsafe fn get_ivar<T>(&self, name: &str) -> &Twhere
T: Encode,
Ivar::load instead.Use Ivar::load instead.
§Safety
The object must have an instance variable with the given name, and it
must be of type T.
See Ivar::load_ptr for details surrounding this.
Sourcepub fn downcast_ref<T>(&self) -> Option<&T>where
T: DowncastTarget,
pub fn downcast_ref<T>(&self) -> Option<&T>where
T: DowncastTarget,
Attempt to downcast the object to a class of type T.
This is the reference-variant. Use Retained::downcast if you want
to convert a retained object to another type.
§Mutable classes
Some classes have immutable and mutable variants, such as NSString
and NSMutableString.
When some Objective-C API signature says it gives you an immutable class, it generally expects you to not mutate that, even though it may technically be mutable “under the hood”.
So using this method to convert a NSString to a NSMutableString,
while not unsound, is generally frowned upon unless you created the
string yourself, or the API explicitly documents the string to be
mutable.
See Apple’s documentation on mutability and on
isKindOfClass: for more details.
§Generic classes
Objective-C generics are called “lightweight generics”, and that’s because they aren’t exposed in the runtime. This makes it impossible to safely downcast to generic collections, so this is disallowed by this method.
You can, however, safely downcast to generic collections where all the
type-parameters are AnyObject.
§Panics
This works internally by calling isKindOfClass:. That means that the
object must have the instance method of that name, and an exception
will be thrown (if CoreFoundation is linked) or the process will abort
if that is not the case. In the vast majority of cases, you don’t need
to worry about this, since both root objects NSObject and
NSProxy implement this method.
§Examples
Cast an NSString back and forth from NSObject.
use objc2::rc::Retained;
use objc2_foundation::{NSObject, NSString};
let obj: Retained<NSObject> = NSString::new().into_super();
let string = obj.downcast_ref::<NSString>().unwrap();
// Or with `downcast`, if we do not need the object afterwards
let string = obj.downcast::<NSString>().unwrap();Try (and fail) to cast an NSObject to an NSString.
use objc2_foundation::{NSObject, NSString};
let obj = NSObject::new();
assert!(obj.downcast_ref::<NSString>().is_none());Try to cast to an array of strings.
use objc2_foundation::{NSArray, NSObject, NSString};
let arr = NSArray::from_retained_slice(&[NSObject::new()]);
// This is invalid and doesn't type check.
let arr = arr.downcast_ref::<NSArray<NSString>>();This fails to compile, since it would require enumerating over the array to ensure that each element is of the desired type, which is a performance pitfall.
Downcast when processing each element instead.
use objc2_foundation::{NSArray, NSObject, NSString};
let arr = NSArray::from_retained_slice(&[NSObject::new()]);
for elem in arr {
if let Some(data) = elem.downcast_ref::<NSString>() {
// handle `data`
}
}Trait Implementations§
Source§impl AsRef<AnyObject> for OBEXFileTransferServices
impl AsRef<AnyObject> for OBEXFileTransferServices
Source§impl AsRef<NSObject> for OBEXFileTransferServices
impl AsRef<NSObject> for OBEXFileTransferServices
Source§impl Borrow<AnyObject> for OBEXFileTransferServices
impl Borrow<AnyObject> for OBEXFileTransferServices
Source§impl Borrow<NSObject> for OBEXFileTransferServices
impl Borrow<NSObject> for OBEXFileTransferServices
Source§impl ClassType for OBEXFileTransferServices
impl ClassType for OBEXFileTransferServices
Source§const NAME: &'static str = "OBEXFileTransferServices"
const NAME: &'static str = "OBEXFileTransferServices"
Source§type ThreadKind = <<OBEXFileTransferServices as ClassType>::Super as ClassType>::ThreadKind
type ThreadKind = <<OBEXFileTransferServices as ClassType>::Super as ClassType>::ThreadKind
Source§impl Debug for OBEXFileTransferServices
impl Debug for OBEXFileTransferServices
Source§impl Deref for OBEXFileTransferServices
impl Deref for OBEXFileTransferServices
Source§impl Hash for OBEXFileTransferServices
impl Hash for OBEXFileTransferServices
Source§impl Message for OBEXFileTransferServices
impl Message for OBEXFileTransferServices
Source§impl NSObjectProtocol for OBEXFileTransferServices
impl NSObjectProtocol for OBEXFileTransferServices
Source§fn isEqual(&self, other: Option<&AnyObject>) -> bool
fn isEqual(&self, other: Option<&AnyObject>) -> bool
Source§fn hash(&self) -> usize
fn hash(&self) -> usize
Source§fn isKindOfClass(&self, cls: &AnyClass) -> bool
fn isKindOfClass(&self, cls: &AnyClass) -> bool
Source§fn is_kind_of<T>(&self) -> bool
fn is_kind_of<T>(&self) -> bool
isKindOfClass directly, or cast your objects with AnyObject::downcast_ref