Skip to main content

ReferenceSyncEnv

Struct ReferenceSyncEnv 

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

Runs folder transfers by stating a transcript instead of moving anything.

Implementations§

Source§

impl ReferenceSyncEnv

Source

pub fn register_transcript(&mut self, lines: impl IntoIterator<Item = String>)

States exactly what the next transfer writes, whatever command it is given.

Source

pub fn refuse_transfers(&mut self, reason: impl Into<String>)

Refuses every subsequent transfer, so failure laws can be exercised.

Source

pub fn commands(&self) -> Vec<SyncCommand>

Observes every command the interpreter was asked to run, in order.

Source

pub fn watched(&self) -> Vec<SyncObservation>

Observes everything the interpreter read out of its transfers, in order.

Trait Implementations§

Source§

impl Clone for ReferenceSyncEnv

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ReferenceSyncEnv

Source§

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

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

impl Default for ReferenceSyncEnv

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl RsyncEndpointAlg for ReferenceSyncEnv

Source§

fn endpoint( &self, user: Option<String>, host: Option<String>, path: impl Into<String>, ) -> Self::Endpoint

Defines one endpoint from the account, the machine, and the path it names. Read more
Source§

impl RsyncEndpointViewAlg for ReferenceSyncEnv

Source§

fn endpoint_user<'a>(&self, endpoint: &'a Self::Endpoint) -> Option<&'a str>

Observes the account the far end is reached as, when one was stated.
Source§

fn endpoint_host<'a>(&self, endpoint: &'a Self::Endpoint) -> Option<&'a str>

Observes the machine the path rests on, and states nothing when the path is here.
Source§

fn endpoint_path<'a>(&self, endpoint: &'a Self::Endpoint) -> &'a str

Observes the path itself.
Source§

impl RsyncSorts for ReferenceSyncEnv

Source§

type Endpoint = RsyncEndpoint

Represents one end of a transfer.
Source§

type Command = SyncCommand

Represents exactly the command one transfer runs.
Source§

type Observation = SyncObservation

Represents one thing a running transfer states.
Source§

type Change = PlannedChange

Represents one path a transfer would change.
Source§

impl SyncChangeAlg for ReferenceSyncEnv

Source§

fn sync_change( &self, path: impl Into<String>, kind: ChangeKind, size: Option<u64>, ) -> Self::Change

Defines one change from the path it names, what happens to it, and what it moves.
Source§

impl SyncCommandAlg for ReferenceSyncEnv

Source§

fn sync_command( &self, program: impl Into<String>, arguments: impl IntoIterator<Item = String>, ) -> Self::Command

Defines the command running one program with exactly these arguments, in this order.
Source§

impl SyncCommandViewAlg for ReferenceSyncEnv

Source§

fn command_program<'a>(&self, command: &'a Self::Command) -> &'a str

Observes the program the transfer is performed by.
Source§

fn command_arguments<'a>( &self, command: &'a Self::Command, ) -> impl Iterator<Item = &'a str>

Observes every argument, in the order the program is given them.
Source§

impl SyncObservationAlg for ReferenceSyncEnv

Source§

fn observed_change(&self, change: Self::Change) -> Self::Observation

Defines the observation of one path the transfer would change, or has changed.
Source§

fn observed_progress(&self, transferred: u64, percent: u16) -> Self::Observation

Defines the observation of how far the whole transfer has come.
Source§

fn observed_nothing(&self) -> Self::Observation

Defines the observation of a line naming nothing this specification reads.
Source§

impl SyncObservationViewAlg for ReferenceSyncEnv

Source§

fn observation_change<'a>( &self, observation: &'a Self::Observation, ) -> Option<&'a Self::Change>

Observes the changed path, exactly when the observation states one.
Source§

fn observation_progress( &self, observation: &Self::Observation, ) -> Option<(u64, u16)>

Observes the bytes moved and the share completed, exactly when the observation states them.
Source§

impl SyncRunAlg for ReferenceSyncEnv

Source§

type Error = ReferenceSyncError

Denotes failure to run the transfer.
Source§

type Run = VecDeque<String>

Carries one running transfer.
Source§

fn start_sync(&self, command: &Self::Command) -> Result<Self::Run, Self::Error>

Starts one transfer command. Read more
Source§

fn next_sync_line( &self, run: &mut Self::Run, ) -> Result<Option<String>, Self::Error>

Reads the next line the running transfer wrote, and states when it has written its last. Read more
Source§

fn finish_sync(&self, _run: Self::Run) -> Result<(), Self::Error>

Waits for the transfer to end and states whether it ended well. Read more
Source§

impl SyncWatchAlg for ReferenceSyncEnv

Source§

fn watch_sync(&self, observation: &Self::Observation)

Applies one observation of the running transfer.

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<This> GaugeLaws<This> for This

Source§

fn gauge_laws(&self) -> Result<(), Error>

Checks that a gauge states a share without claiming more resolution than it has.

The laws checked are:

  1. a gauge occupies its stated width whatever share it states;
  2. no share is stated as filled before it is reached, and none is stated twice;
  3. nothing stated is nothing filled, and everything stated fills the whole track;
  4. the stated text occupies exactly one cell per counted cell.
§Errors

Returns the first violated law.

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

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<This> IntoExt<This> for This

Source§

fn to<R>(self) -> R
where This: Into<R>,

A version of Into::into function that can be used to explicitly specify the target conversion type.

use alux_sdk::*;
// `Into` requires context to infer the type,
let _: i64 = Into::into(42_i8);
// The opposite `From` requires context to infer the type,
let _: i64 = From::from(42_i8);
// `.to()` can be used in the same way as a postfix function (the same as `.into()`),
let _: i64 = 42_i8.to();
// but also with the type specified explicitly.
let _ = 42_i8.to::<i64>();
// Especially useful to chain multiple conversions inline.
let _: i64 = 42_i8.to::<i16>().to::<i32>().into();
Source§

impl<This> IntoIteratorExt<This> for This

Source§

fn try_collect_vec<T, E>(self) -> Result<Vec<T>, E>
where This: Iterator<Item = Result<T, E>>,

A variant of the try_collect and collect_vec combined function from the Itertools library. The materialized value is a Vec inside a Result object.

Returns the first error without collecting later values.

use alux_sdk::*;

let values = [Ok::<_, &str>(1), Ok(2), Ok(3)]
    .into_iter()
    .try_collect_vec();

assert_eq!(values, Ok(vec![1, 2, 3]));
Source§

fn collect_exact<T>(self, n: usize) -> Option<Vec<T>>
where This: Iterator<Item = T>,

Takes exactly n elements from the iterator.

Returns Some(Vec<T>) if the iterator yields exactly n elements, otherwise returns None.

use alux_sdk::*;

let v = [1, 2, 3];

assert_eq!(v.iter().copied().collect_exact(3), Some(vec![1, 2, 3]));
assert_eq!(v.iter().copied().collect_exact(4), None);
assert_eq!(v.iter().copied().collect_exact(2), None);
Source§

fn try_unzip<A, B, E>(self) -> Result<(Vec<A>, Vec<B>), E>
where This: IntoIterator<Item = Result<(A, B), E>>,

Efficiently splits an iterator of Result<(A, B), E> into two Vecs, short-circuiting on error.

Consumes the iterator, collecting all A elements into one vector and all B elements into another, without first allocating an intermediate vector of tuples. Returns the tuple (Vec<A>, Vec<B>) on success, or the first error encountered.

use alux_sdk::*;

let input = vec![Ok((1, "x")), Ok((2, "y"))];
let (xs, ys) = input.try_unzip::<_, _, ()>().unwrap();

assert_eq!(xs, vec![1, 2]);
assert_eq!(ys, vec!["x", "y"]);
Source§

impl<This> RsyncEndpointExt<This> for This

Source§

fn read_endpoint(&self, input: &str) -> <This as RsyncSorts>::Endpoint

Reads one endpoint from the text somebody submitted.

Three shapes name a path on another machine: a daemon URL, and a machine and a path separated by a colon with nothing path-like before it. A text naming any other scheme names a resource somewhere else, and a text naming neither names a path here.

Source§

fn read_transfer( &self, line: &str, ) -> Option<(<This as RsyncSorts>::Endpoint, <This as RsyncSorts>::Endpoint)>

Reads one submitted line as the two ends of a transfer, when it names two.

A transfer is written the way it is run: what comes from, then what it comes to. Anything naming how rather than what — the program itself, and the arguments given to it — is already stated by the transfer, so a whole command can be submitted and still be read.

Source§

fn endpoint_remote(&self, endpoint: &<This as RsyncSorts>::Endpoint) -> bool

Observes whether the path rests on another machine.

Source§

fn endpoint_text(&self, endpoint: &<This as RsyncSorts>::Endpoint) -> String

States the endpoint the way the transfer program is given it.

Source§

fn endpoint_name<'a>( &self, endpoint: &'a <This as RsyncSorts>::Endpoint, ) -> &'a str

Names what the path ends with, without the path that leads to it.

Source§

impl<This> SyncCommandExt<This> for This

Source§

fn transfer_command( &self, source: &<This as RsyncSorts>::Endpoint, destination: &<This as RsyncSorts>::Endpoint, mode: SyncMode, ) -> <This as RsyncSorts>::Command

States the command transferring one endpoint into another.

What is transferred may be one file or a whole folder, and each end is stated exactly as it was written. A source ending with a separator names the contents of a folder; one without names the path itself, which comes to rest inside the destination. Both are wanted, so neither is invented here.

Source§

fn command_rehearses(&self, command: &<This as RsyncSorts>::Command) -> bool

Observes whether the command states what it would do instead of doing it.

Source§

fn command_mirrors(&self, command: &<This as RsyncSorts>::Command) -> bool

Observes whether the command removes what the source no longer holds.

Source§

impl<This> SyncProgramExt<This> for This

Source§

fn run_sync( &self, command: &<This as RsyncSorts>::Command, ) -> Result<Vec<<This as RsyncSorts>::Change>, <This as SyncRunAlg>::Error>

Runs one transfer and states every change it named, in the order it named them.

Every line is watched as it arrives, so an interpreter following a transfer sees progress while it runs rather than after it ends.

§Errors

Returns the failure that started, read, or ended the transfer.

Source§

impl<This> SyncReadExt<This> for This

Source§

fn read_sync_line(&self, line: &str) -> <This as RsyncSorts>::Observation

Reads one line the transfer program wrote as what it states.

A change is stated in three fields: the flags naming what happens, the byte count, and the path. Anything else on the stream is progress, or is nothing this specification reads.

Source§

fn read_sync_change(&self, line: &str) -> Option<<This as RsyncSorts>::Change>

Reads one itemized line as the change it denotes, and states nothing for a line naming only that a folder was opened on the way to what is inside it.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.