Skip to main content

AfcClient

Struct AfcClient 

Source
pub struct AfcClient<S> { /* private fields */ }
Expand description

AFC file-system client.

S must be a full-duplex async stream (e.g. the raw usbmux stream from lockdown).

Implementations§

Source§

impl<S: AsyncRead + AsyncWrite + Unpin> AfcClient<S>

Source

pub const FILE_MODE_READ_ONLY: u64 = 0x00000001

Source

pub const FILE_MODE_READ_WRITE: u64 = 0x00000002

Source

pub const FILE_MODE_WRITE_ONLY_CREATE_TRUNC: u64 = 0x00000003

Source

pub const LOCK_EXCLUSIVE: u64

Source

pub const LOCK_UNLOCK: u64

Source

pub fn new(stream: S) -> Self

Source

pub async fn list_dir(&mut self, path: &str) -> Result<Vec<String>, AfcError>

List directory entries (excludes “.” and “..”).

The AFC device returns null-separated filenames in the payload section of the response frame (entire_len > this_len).

Source

pub async fn stat( &mut self, path: &str, ) -> Result<HashMap<String, String>, AfcError>

Get key-value file info for a path.

Source

pub async fn stat_info(&mut self, path: &str) -> Result<AfcFileInfo, AfcError>

Get parsed file info for a path.

AFC reports st_mode as an octal string. This helper parses it into a u32, matching go-ios behavior.

Source

pub async fn make_dir(&mut self, path: &str) -> Result<(), AfcError>

Create a directory.

Source

pub async fn remove(&mut self, path: &str) -> Result<(), AfcError>

Remove a path (file or empty directory).

Source

pub async fn remove_all(&mut self, path: &str) -> Result<(), AfcError>

Remove a path and all contents recursively.

Source

pub async fn rename(&mut self, from: &str, to: &str) -> Result<(), AfcError>

Rename / move a path.

Source

pub async fn read_file(&mut self, path: &str) -> Result<Bytes, AfcError>

Read an entire file into memory.

Read an entire file into memory, following a single AFC symlink.

This matches go-ios PullSingleFile behavior: if the source path is a symlink, AFC reports the target in st_linktarget and the file is read from that target path instead.

Source

pub async fn write_file( &mut self, path: &str, data: &[u8], ) -> Result<(), AfcError>

Write data to a file (creates or truncates).

Source

pub async fn write_file_from_reader<R>( &mut self, path: &str, reader: &mut R, ) -> Result<(), AfcError>
where R: AsyncRead + Unpin,

Write data from an async reader to a file (creates or truncates).

Source

pub async fn open_file( &mut self, path: &str, mode: u64, ) -> Result<u64, AfcError>

Source

pub async fn lock_file( &mut self, fd: u64, operation: u64, ) -> Result<(), AfcError>

Source

pub async fn close_file(&mut self, fd: u64) -> Result<(), AfcError>

Source

pub async fn device_info(&mut self) -> Result<HashMap<String, String>, AfcError>

Get device filesystem info.

Auto Trait Implementations§

§

impl<S> Freeze for AfcClient<S>
where S: Freeze,

§

impl<S> RefUnwindSafe for AfcClient<S>
where S: RefUnwindSafe,

§

impl<S> Send for AfcClient<S>
where S: Send,

§

impl<S> Sync for AfcClient<S>
where S: Sync,

§

impl<S> Unpin for AfcClient<S>
where S: Unpin,

§

impl<S> UnsafeUnpin for AfcClient<S>
where S: UnsafeUnpin,

§

impl<S> UnwindSafe for AfcClient<S>
where S: UnwindSafe,

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> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more