pub struct ReferenceSyncEnv { /* private fields */ }Expand description
Runs folder transfers by stating a transcript instead of moving anything.
Implementations§
Source§impl ReferenceSyncEnv
impl ReferenceSyncEnv
Sourcepub fn register_transcript(&mut self, lines: impl IntoIterator<Item = String>)
pub fn register_transcript(&mut self, lines: impl IntoIterator<Item = String>)
States exactly what the next transfer writes, whatever command it is given.
Sourcepub fn refuse_transfers(&mut self, reason: impl Into<String>)
pub fn refuse_transfers(&mut self, reason: impl Into<String>)
Refuses every subsequent transfer, so failure laws can be exercised.
Sourcepub fn commands(&self) -> Vec<SyncCommand>
pub fn commands(&self) -> Vec<SyncCommand>
Observes every command the interpreter was asked to run, in order.
Sourcepub fn watched(&self) -> Vec<SyncObservation>
pub fn watched(&self) -> Vec<SyncObservation>
Observes everything the interpreter read out of its transfers, in order.
Trait Implementations§
Source§impl Clone for ReferenceSyncEnv
impl Clone for ReferenceSyncEnv
Source§impl Debug for ReferenceSyncEnv
impl Debug for ReferenceSyncEnv
Source§impl Default for ReferenceSyncEnv
impl Default for ReferenceSyncEnv
Source§impl RsyncEndpointAlg for ReferenceSyncEnvwhere
RsyncSyntax: RsyncEndpointAlg,
impl RsyncEndpointAlg for ReferenceSyncEnvwhere
RsyncSyntax: RsyncEndpointAlg,
Source§impl RsyncEndpointViewAlg for ReferenceSyncEnvwhere
RsyncSyntax: RsyncEndpointViewAlg,
impl RsyncEndpointViewAlg for ReferenceSyncEnvwhere
RsyncSyntax: RsyncEndpointViewAlg,
Source§fn endpoint_user<'a>(&self, endpoint: &'a Self::Endpoint) -> Option<&'a str>
fn endpoint_user<'a>(&self, endpoint: &'a Self::Endpoint) -> Option<&'a str>
Source§fn endpoint_host<'a>(&self, endpoint: &'a Self::Endpoint) -> Option<&'a str>
fn endpoint_host<'a>(&self, endpoint: &'a Self::Endpoint) -> Option<&'a str>
Source§fn endpoint_path<'a>(&self, endpoint: &'a Self::Endpoint) -> &'a str
fn endpoint_path<'a>(&self, endpoint: &'a Self::Endpoint) -> &'a str
Source§impl RsyncSorts for ReferenceSyncEnv
impl RsyncSorts for ReferenceSyncEnv
Source§type Endpoint = RsyncEndpoint
type Endpoint = RsyncEndpoint
Source§type Command = SyncCommand
type Command = SyncCommand
Source§type Observation = SyncObservation
type Observation = SyncObservation
Source§type Change = PlannedChange
type Change = PlannedChange
Source§impl SyncChangeAlg for ReferenceSyncEnvwhere
RsyncSyntax: SyncChangeAlg,
impl SyncChangeAlg for ReferenceSyncEnvwhere
RsyncSyntax: SyncChangeAlg,
Source§fn sync_change(
&self,
path: impl Into<String>,
kind: ChangeKind,
size: Option<u64>,
) -> Self::Change
fn sync_change( &self, path: impl Into<String>, kind: ChangeKind, size: Option<u64>, ) -> Self::Change
Source§impl SyncCommandAlg for ReferenceSyncEnvwhere
RsyncSyntax: SyncCommandAlg,
impl SyncCommandAlg for ReferenceSyncEnvwhere
RsyncSyntax: SyncCommandAlg,
Source§fn sync_command(
&self,
program: impl Into<String>,
arguments: impl IntoIterator<Item = String>,
) -> Self::Command
fn sync_command( &self, program: impl Into<String>, arguments: impl IntoIterator<Item = String>, ) -> Self::Command
Source§impl SyncCommandViewAlg for ReferenceSyncEnvwhere
RsyncSyntax: SyncCommandViewAlg,
impl SyncCommandViewAlg for ReferenceSyncEnvwhere
RsyncSyntax: SyncCommandViewAlg,
Source§impl SyncObservationAlg for ReferenceSyncEnvwhere
RsyncSyntax: SyncObservationAlg,
impl SyncObservationAlg for ReferenceSyncEnvwhere
RsyncSyntax: SyncObservationAlg,
Source§fn observed_change(&self, change: Self::Change) -> Self::Observation
fn observed_change(&self, change: Self::Change) -> Self::Observation
Source§fn observed_progress(&self, transferred: u64, percent: u16) -> Self::Observation
fn observed_progress(&self, transferred: u64, percent: u16) -> Self::Observation
Source§fn observed_nothing(&self) -> Self::Observation
fn observed_nothing(&self) -> Self::Observation
Source§impl SyncObservationViewAlg for ReferenceSyncEnvwhere
RsyncSyntax: SyncObservationViewAlg,
impl SyncObservationViewAlg for ReferenceSyncEnvwhere
RsyncSyntax: SyncObservationViewAlg,
Source§fn observation_change<'a>(
&self,
observation: &'a Self::Observation,
) -> Option<&'a Self::Change>
fn observation_change<'a>( &self, observation: &'a Self::Observation, ) -> Option<&'a Self::Change>
Source§fn observation_progress(
&self,
observation: &Self::Observation,
) -> Option<(u64, u16)>
fn observation_progress( &self, observation: &Self::Observation, ) -> Option<(u64, u16)>
Source§impl SyncRunAlg for ReferenceSyncEnv
impl SyncRunAlg for ReferenceSyncEnv
Source§type Error = ReferenceSyncError
type Error = ReferenceSyncError
Source§fn start_sync(&self, command: &Self::Command) -> Result<Self::Run, Self::Error>
fn start_sync(&self, command: &Self::Command) -> Result<Self::Run, Self::Error>
Source§impl SyncWatchAlg for ReferenceSyncEnv
impl SyncWatchAlg for ReferenceSyncEnv
Source§fn watch_sync(&self, observation: &Self::Observation)
fn watch_sync(&self, observation: &Self::Observation)
Auto Trait Implementations§
impl !Freeze for ReferenceSyncEnv
impl !RefUnwindSafe for ReferenceSyncEnv
impl !Sync for ReferenceSyncEnv
impl Send for ReferenceSyncEnv
impl Unpin for ReferenceSyncEnv
impl UnsafeUnpin for ReferenceSyncEnv
impl UnwindSafe for ReferenceSyncEnv
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<This> GaugeLaws<This> for This
impl<This> GaugeLaws<This> for This
Source§fn gauge_laws(&self) -> Result<(), Error>
fn gauge_laws(&self) -> Result<(), Error>
Checks that a gauge states a share without claiming more resolution than it has.
The laws checked are:
- a gauge occupies its stated width whatever share it states;
- no share is stated as filled before it is reached, and none is stated twice;
- nothing stated is nothing filled, and everything stated fills the whole track;
- the stated text occupies exactly one cell per counted cell.
§Errors
Returns the first violated law.
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
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 moreSource§impl<This> IntoExt<This> for This
impl<This> IntoExt<This> for This
Source§fn to<R>(self) -> Rwhere
This: Into<R>,
fn to<R>(self) -> Rwhere
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
impl<This> IntoIteratorExt<This> for This
Source§fn try_collect_vec<T, E>(self) -> Result<Vec<T>, E>
fn try_collect_vec<T, E>(self) -> Result<Vec<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>,
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>
fn try_unzip<A, B, E>(self) -> Result<(Vec<A>, Vec<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 Thiswhere
This: RsyncEndpointAlg + RsyncEndpointViewAlg,
impl<This> RsyncEndpointExt<This> for Thiswhere
This: RsyncEndpointAlg + RsyncEndpointViewAlg,
Source§fn read_endpoint(&self, input: &str) -> <This as RsyncSorts>::Endpoint
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)>
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
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
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
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
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
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
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
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 Thiswhere
This: SyncRunAlg + SyncWatchAlg + SyncChangeAlg + SyncObservationAlg + SyncObservationViewAlg,
<This as RsyncSorts>::Change: Clone,
impl<This> SyncProgramExt<This> for Thiswhere
This: SyncRunAlg + SyncWatchAlg + SyncChangeAlg + SyncObservationAlg + SyncObservationViewAlg,
<This as RsyncSorts>::Change: Clone,
Source§fn run_sync(
&self,
command: &<This as RsyncSorts>::Command,
) -> Result<Vec<<This as RsyncSorts>::Change>, <This as SyncRunAlg>::Error>
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 Thiswhere
This: SyncChangeAlg + SyncObservationAlg,
impl<This> SyncReadExt<This> for Thiswhere
This: SyncChangeAlg + SyncObservationAlg,
Source§fn read_sync_line(&self, line: &str) -> <This as RsyncSorts>::Observation
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>
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.