UpgradeConfig

Struct UpgradeConfig 

Source
pub struct UpgradeConfig {
    pub check_on_startup: bool,
    pub check_interval: u64,
    pub auto_backup: bool,
    pub verify_checksum: bool,
}
Expand description

Configuration settings for AGPM self-update behavior.

UpgradeConfig defines how AGPM handles automatic update checking, backup creation, and security verification during upgrades. These settings can be configured globally or per-project to control update behavior.

§Configuration Categories

§Update Timing

  • Startup Checks: Whether to check for updates when AGPM starts
  • Check Intervals: How frequently to perform background update checks

§Safety Settings

  • Automatic Backups: Whether to create backups before upgrades
  • Checksum Verification: Whether to verify download integrity

§Default Behavior

The default configuration prioritizes safety and user control:

  • No automatic update checking on startup (avoids startup delays)
  • 24-hour intervals for update checks (balances freshness with performance)
  • Always create backups (enables rollback on failures)
  • Always verify checksums (ensures download integrity)

§Examples

§Using Default Configuration

use agpm_cli::upgrade::config::UpgradeConfig;

let config = UpgradeConfig::default();
assert_eq!(config.check_on_startup, false);
assert_eq!(config.auto_backup, true);

§Custom Configuration

use agpm_cli::upgrade::config::UpgradeConfig;

let config = UpgradeConfig {
    check_on_startup: true,
    check_interval: 3600, // 1 hour
    auto_backup: true,
    verify_checksum: true,
};

§Serialization

This configuration can be serialized to TOML, JSON, or other formats supported by serde for storage in configuration files.

§TOML Example

[upgrade]
check_on_startup = false
check_interval = 86400
auto_backup = true
verify_checksum = true

Fields§

§check_on_startup: bool

Whether to check for updates when AGPM starts.

When enabled, AGPM will perform a background check for updates every time it starts up. This provides the earliest notification of available updates but may slightly delay startup time.

§Default: false

Disabled by default to avoid slowing down CLI operations. Users can manually check for updates using agpm upgrade --check.

§Considerations

  • Startup Performance: Adds network delay to every AGPM invocation
  • Network Dependency: May fail or timeout in poor network conditions
  • Rate Limiting: Frequent use may hit GitHub API rate limits
  • User Experience: Can be intrusive for automated scripts
§check_interval: u64

Interval between automatic update checks in seconds.

Controls how frequently AGPM performs background checks for new versions. This setting balances update notification timeliness with network usage and API rate limit consumption.

§Default: 86400 (24 hours)

The default 24-hour interval provides daily update notifications while being respectful of GitHub’s API rate limits.

  • 3600 (1 hour): For development environments or beta testing
  • 21600 (6 hours): For active development workflows
  • 86400 (1 day): Standard for most users (default)
  • 604800 (1 week): For stable environments with infrequent updates

§Rate Limiting

GitHub allows 60 unauthenticated API requests per hour per IP address. Setting intervals below 1 minute may exceed rate limits with heavy usage.

§auto_backup: bool

Whether to automatically create backups before upgrades.

When enabled, AGPM creates a backup copy of the current binary before attempting any upgrade. This enables rollback if the upgrade fails or the new version has issues.

§Default: true

Enabled by default for maximum safety. Backups use minimal disk space and provide crucial recovery capability.

§Backup Process

  • Creates a copy with .backup suffix in the same directory
  • Preserves file permissions and metadata
  • Automatically removed after successful upgrades
  • Can be restored manually or via agpm upgrade --rollback

§Disabling Backups

Consider disabling only in environments where:

  • Disk space is severely constrained
  • File system permissions prevent backup creation
  • Alternative backup/recovery mechanisms are in place
  • Upgrade failures can be resolved through reinstallation
§verify_checksum: bool

Whether to verify checksums of downloaded binaries.

When enabled, AGPM verifies the integrity of downloaded binaries by comparing their checksums against expected values. This provides protection against corrupted downloads and potential security issues.

§Default: true

Enabled by default for security and reliability. Checksum verification adds minimal overhead but provides important integrity guarantees.

§Security Benefits

  • Download Integrity: Detects corrupted or incomplete downloads
  • Tamper Detection: Identifies potentially modified binaries
  • Supply Chain Security: Helps ensure binary authenticity
  • Network Reliability: Catches network-induced corruption

§Verification Process

  • Downloads expected checksums from GitHub releases
  • Computes actual checksum of downloaded binary
  • Compares checksums before proceeding with installation
  • Aborts upgrade if checksums don’t match

§Disabling Verification

Consider disabling only in environments where:

  • Network reliability is extremely poor
  • Checksum information is unavailable from releases
  • Alternative integrity verification is in place
  • Testing scenarios require bypassing verification

Implementations§

Source§

impl UpgradeConfig

Source

pub fn new() -> Self

Create a new UpgradeConfig with default settings.

This is equivalent to Default::default() but provides a more conventional constructor-style interface for creating configurations.

§Examples
use agpm_cli::upgrade::config::UpgradeConfig;

// These are equivalent
let config1 = UpgradeConfig::new();
let config2 = UpgradeConfig::default();

assert_eq!(config1.check_on_startup, config2.check_on_startup);
assert_eq!(config1.auto_backup, config2.auto_backup);
§See Also

Trait Implementations§

Source§

impl Clone for UpgradeConfig

Source§

fn clone(&self) -> UpgradeConfig

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 UpgradeConfig

Source§

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

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

impl Default for UpgradeConfig

Source§

fn default() -> Self

Create an UpgradeConfig with safe, conservative defaults.

The default configuration prioritizes safety, reliability, and user control over aggressive update checking. This approach:

  • Avoids surprising users with automatic behavior
  • Minimizes impact on CLI performance
  • Provides maximum safety during upgrades
  • Respects GitHub API rate limits
§Default Values
  • check_on_startup: false - No startup delays
  • check_interval: 86400 (24 hours) - Daily update checks
  • auto_backup: true - Always create backups for safety
  • verify_checksum: true - Always verify download integrity
§Examples
use agpm_cli::upgrade::config::UpgradeConfig;

let config = UpgradeConfig::default();
assert_eq!(config.check_on_startup, false);
assert_eq!(config.check_interval, 86400);
assert_eq!(config.auto_backup, true);
assert_eq!(config.verify_checksum, true);
Source§

impl<'de> Deserialize<'de> for UpgradeConfig

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Serialize for UpgradeConfig

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. 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> 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> 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<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
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> 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

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
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,