Expose reset as well
This commit is contained in:
parent
fabb6bd8cc
commit
562f09c1f6
2 changed files with 24 additions and 0 deletions
|
|
@ -175,6 +175,12 @@ Hasher_dealloc(PyObject *self) {
|
|||
Py_TYPE(self)->tp_free(self);
|
||||
}
|
||||
|
||||
static PyObject*
|
||||
reset(Hasher *self) {
|
||||
if (!self->h.reset(self->h.state)) return PyErr_NoMemory();
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
|
||||
static PyObject*
|
||||
update(Hasher *self, PyObject *o) {
|
||||
FREE_BUFFER_AFTER_FUNCTION Py_buffer data = {0};
|
||||
|
|
@ -217,6 +223,7 @@ static PyMethodDef Hasher_methods[] = {
|
|||
METHODB(update, METH_O),
|
||||
METHODB(digest, METH_NOARGS),
|
||||
METHODB(hexdigest, METH_NOARGS),
|
||||
METHODB(reset, METH_NOARGS),
|
||||
{NULL} /* Sentinel */
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -1,3 +1,20 @@
|
|||
from typing import Union
|
||||
|
||||
Buffer = Union[bytes, bytearray, memoryview]
|
||||
|
||||
class RsyncError(Exception):
|
||||
pass
|
||||
|
||||
class Hasher:
|
||||
def __init__(self, which: str, data: Buffer = b''): ...
|
||||
def update(self, data: Buffer) -> None: ...
|
||||
def reset(self) -> None: ...
|
||||
def digest(self) -> bytes: ...
|
||||
def hexdigest(self) -> str: ...
|
||||
|
||||
@property
|
||||
def digest_size(self) -> int: ...
|
||||
@property
|
||||
def block_size(self) -> int: ...
|
||||
@property
|
||||
def name(self) -> str: ...
|
||||
|
|
|
|||
Loading…
Reference in a new issue