ExternalConfig

Struct ExternalConfig 

Source
pub struct ExternalConfig {
    pub id: String,
    pub archive_filename: String,
    pub display_name: String,
    pub description: Option<String>,
    pub export_source: ExportSource,
    pub import_target: ImportTarget,
    pub is_sensitive: bool,
    pub optional: bool,
    pub is_directory: bool,
}
Expand description

External configuration managed by the app

Use this to register external files, command outputs, or dynamic data that should be available for backup export and restore.

§Examples

§File-based config (traditional)

use rcman::ExternalConfig;

let config = ExternalConfig::new("rclone_config", "/path/to/rclone.conf")
    .display_name("Rclone Configuration");

§Command output

use rcman::ExternalConfig;

let config = ExternalConfig::from_command("rclone_dump", "rclone_dump.json")
    .export_command("rclone", &["config", "dump"])
    .import_read_only() // Cannot restore command output directly
    .display_name("Rclone Config Dump");

§In-memory content

use rcman::ExternalConfig;

let api_data = b"{ \"key\": \"value\" }".to_vec();
let config = ExternalConfig::from_content("cloud_config", "cloud.json", api_data)
    .display_name("Cloud Settings");

Fields§

§id: String

Unique identifier for referencing in BackupOptions

§archive_filename: String

Filename used inside the backup archive

§display_name: String

Human-readable name for display

§description: Option<String>

Description of what this config contains

§export_source: ExportSource

How to get the data for export

§import_target: ImportTarget

How to restore the data on import

§is_sensitive: bool

Whether this config contains sensitive data

§optional: bool

Whether this config is optional for export (default: false)

§is_directory: bool

Whether this is a directory (for File source, default: false)

Implementations§

Source§

impl ExternalConfig

Source

pub fn new(id: impl Into<String>, path: impl Into<PathBuf>) -> Self

Create a new file-based external config (backward compatible)

This is the traditional way to register a config file. Both export and import will use the same file path.

§Arguments
  • id - Unique identifier (used in BackupOptions::include_external)
  • path - Path to the file or directory
Source

pub fn from_command( id: impl Into<String>, archive_filename: impl Into<String>, ) -> Self

Create a config that exports from a command’s stdout

§Arguments
  • id - Unique identifier
  • archive_filename - Filename to use inside the backup archive
Source

pub fn from_content( id: impl Into<String>, archive_filename: impl Into<String>, content: Vec<u8>, ) -> Self

Create a config from in-memory content

§Arguments
  • id - Unique identifier
  • archive_filename - Filename to use inside the backup archive
  • content - The bytes to include in the backup
Source

pub fn export_command(self, program: impl Into<String>, args: &[&str]) -> Self

Set the export command (for Command source)

Source

pub fn import_file(self, path: impl Into<PathBuf>) -> Self

Set import to write to a file

Source

pub fn import_command(self, program: impl Into<String>, args: &[&str]) -> Self

Set import to pipe to a command’s stdin

Source

pub fn import_handler<F>(self, handler: F) -> Self
where F: Fn(&[u8]) -> Result<()> + Send + Sync + 'static,

Set import to use a custom handler

Source

pub fn import_read_only(self) -> Self

Mark import as read-only (cannot be restored)

Source

pub fn display_name(self, name: impl Into<String>) -> Self

Set a human-readable display name

Source

pub fn description(self, desc: impl Into<String>) -> Self

Set a description

Source

pub fn sensitive(self) -> Self

Mark this config as containing sensitive data

Source

pub fn optional(self) -> Self

Mark this config as optional (not included by default in full backup)

Source

pub fn directory(self) -> Self

Mark this as a directory instead of a file (only for File source)

Source

pub fn exists(&self) -> bool

Check if the source exists (only meaningful for File source)

Trait Implementations§

Source§

impl Clone for ExternalConfig

Source§

fn clone(&self) -> ExternalConfig

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for ExternalConfig

Source§

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

Formats the value using the given formatter. Read more

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

Source§

type Output = T

Should always be Self
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 = 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