Skip to main content

SftpFs

Struct SftpFs 

Source
pub struct SftpFs { /* private fields */ }

Implementations§

Source§

impl SftpFs

Source

pub async fn connect(host: &str) -> Result<Self>

Source

pub fn is_alive(&self) -> bool

Whether this connection is still worth sending a request down.

The driver task owns the ssh child’s pipes and returns when they close, which drops the receiving end of this channel. So a shut channel is not a proxy for “the ssh died” – it is the same event, observed from the only side that can see it without a syscall.

Racy by nature: a connection alive when this is asked can be gone by the time the request lands. That is fine, because the caller retries either way. What this prevents is the other thing – holding a corpse forever and answering every request with sftp session is gone until somebody restarts the daemon.

Source

pub async fn over<W, R>(w: W, r: R) -> Result<Self>
where W: AsyncWrite + Unpin + Send + 'static, R: AsyncRead + Unpin + Send + 'static,

Drive a session over arbitrary streams. Exists so the round-trip invariant can be asserted against an in-memory server, with no ssh anywhere.

Trait Implementations§

Source§

impl RemoteFs for SftpFs

Source§

async fn read_batch(&self, paths: &[String]) -> Vec<Result<Vec<u8>>>

Read whole files. Implementations must issue every request before awaiting any reply; doing otherwise silently reintroduces O(N) round trips.
Source§

async fn read_ranges(&self, reqs: &[RangeReq]) -> Vec<Result<Vec<u8>>>

Read byte ranges. Chunking is the implementation’s business; what matters here is that the whole set is issued together, so a one-megabyte range costs one round trip rather than the thirty-two its chunks would suggest.
Source§

async fn home(&self) -> Result<String>

The absolute path a fresh session starts in — the account’s home directory. Read more
Source§

async fn list_dirs(&self, paths: &[String]) -> Vec<Result<Vec<Entry>>>

List several directories at once. One listing carries every entry’s attrs, which is what removes per-file stat from the page path; batching the listings is what holds a symlink check over a deep path at one round trip rather than one per path component.
Source§

fn round_trips(&self) -> u64

Flushes issued so far. One flush is one remote round trip, so this is the invariant made observable. Read more
Source§

async fn list_dir(&self, path: &str) -> Result<Vec<Entry>>

The n=1 case, defined in terms of the batch so that no implementation can quietly make the single listing the cheap path and the batch a loop.

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<'a, T, E> AsTaggedExplicit<'a, E> for T
where T: 'a,

Source§

fn explicit(self, class: Class, tag: u32) -> TaggedParser<'a, Explicit, Self, E>

Source§

impl<'a, T, E> AsTaggedImplicit<'a, E> for T
where T: 'a,

Source§

fn implicit( self, class: Class, constructed: bool, tag: u32, ) -> TaggedParser<'a, Implicit, Self, E>

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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.