pub struct Signature { /* private fields */ }
Expand description

A identifier of a file, much smaller than the file itself.

See crate-level documentation for more details.

Implementations

Creates a new SignatureBuilder in which data can be added to create a list of hashes for blocks the size of block_size.

I recommend block size 4096 for remote transfers. If small documents are what’s mostly being transmitted, consider 512. Consider running Difference::minify if getting the smallest diff is your concern.

This creates a signature of a resource. The signature takes up much less space than the resource.

Larger block_sizes will take more less to compute but signatures become larger, as if a block’s contents isn’t found, it has to send block_size bytes of data. Smaller block_sizes takes more time to compute, but send data in the Signature. Diffs with smaller block_sizes also have the advantage of interfering less with changes if applied to data other than what’s written to the signature.

The HashAlgorithm is chosen using experience with hasher’s performance and heuristics. You can query the algorithm using Self::algorithm.

Panics

Panics if block_size is 0.

This will create a new SignatureBuilder with the algorithm. Consider using Self::new if you don’t know exactly what you are doing, as it sets the algorithm for you. You can query the algorithm using Self::algorithm.

See Self::new for more details and insights into how to choose block_size.

Panics

Will panic if HashAlgorithm is of type None* and block_size is larger than the HashAlgorithm. Also panics if block_size is 0.

Get the algorithm used by this signature.

Returns the block size of this signature.

Get the Difference between the data the Signature represents and the local data.

This will return a struct which when serialized (using e.g. bincode) is much smaller than data.

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Deserialize this value from the given Serde deserializer. Read more

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The resulting type after obtaining ownership.

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

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.