Struct glib::Checksum[][src]

pub struct Checksum(_);
Expand description

An opaque structure representing a checksumming operation. To create a new GChecksum, use new(). To free a GChecksum, use g_checksum_free().

Implementations

Creates a new Checksum, using the checksum algorithm checksum_type. If the checksum_type is not known, None is returned. A Checksum can be used to compute the checksum, or digest, of an arbitrary binary blob, using different hashing algorithms.

A Checksum works by feeding a binary blob through update() until there is data to be checked; the digest can then be extracted using string(), which will return the checksum as a hexadecimal string; or digest(), which will return a vector of raw bytes. Once either string() or digest() have been called on a Checksum, the checksum will be closed and it won’t be possible to call update() on it anymore.

checksum_type

the desired type of checksum

Returns

the newly created Checksum, or None. Use g_checksum_free() to free the memory allocated by it.

Resets the state of the self back to its initial state.

Feeds data into an existing Checksum. The checksum must still be open, that is string() or digest() must not have been called on self.

data

buffer used to compute the checksum

Gets the length in bytes of digests of type checksum_type

checksum_type

a ChecksumType

Returns

the checksum length, or -1 if checksum_type is not supported.

Gets the digest from self as a raw binary vector and places it into buffer. The size of the digest depends on the type of checksum.

Once this function has been called, the Checksum is closed and can no longer be updated with update().

buffer

output buffer

Gets the digest as a hexadecimal string.

Once this function has been called the Checksum can no longer be updated with update().

The hexadecimal characters will be lower case.

Returns

the hexadecimal representation of the checksum. The returned string is owned by the checksum and should not be modified or freed.

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

Feeds this value into the given Hasher. Read more

Feeds a slice of this type into the given Hasher. Read more

This method returns an Ordering between self and other. Read more

Compares and returns the maximum of two values. Read more

Compares and returns the minimum of two values. Read more

Restrict a value to a certain interval. Read more

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

This method tests for !=.

This method returns an ordering between self and other values if one exists. Read more

This method tests less than (for self and other) and is used by the < operator. Read more

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more

This method tests greater than (for self and other) and is used by the > operator. Read more

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more

Returns the type identifier of Self.

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

Performs the conversion.

Performs the conversion.

The resulting type after obtaining ownership.

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

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

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

Returns a SendValue clone of self.

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.