]>
git.proxmox.com Git - proxmox-backup.git/blob - src/task.rs
3 /// `WorkerTask` methods commonly used from contexts otherwise not related to the API server.
5 /// If the task should be aborted, this should fail with a reasonable error message.
6 fn check_abort(&self) -> Result
<(), Error
>;
8 /// Create a log message for this task.
9 fn log(&self, level
: log
::Level
, message
: &std
::fmt
::Arguments
);
12 /// Convenience implementation:
13 impl<T
: TaskState
+ ?Sized
> TaskState
for std
::sync
::Arc
<T
> {
14 fn check_abort(&self) -> Result
<(), Error
> {
15 <T
as TaskState
>::check_abort(&*self)
18 fn log(&self, level
: log
::Level
, message
: &std
::fmt
::Arguments
) {
19 <T
as TaskState
>::log(&*self, level
, message
)
24 macro_rules
! task_error
{
25 ($task
:expr
, $
($fmt
:tt
)+) => {{
26 $
crate::task
::TaskState
::log(&*$task
, log
::Level
::Error
, &format_args
!($
($fmt
)+))
31 macro_rules
! task_warn
{
32 ($task
:expr
, $
($fmt
:tt
)+) => {{
33 $
crate::task
::TaskState
::log(&*$task
, log
::Level
::Warn
, &format_args
!($
($fmt
)+))
38 macro_rules
! task_log
{
39 ($task
:expr
, $
($fmt
:tt
)+) => {{
40 $
crate::task
::TaskState
::log(&*$task
, log
::Level
::Info
, &format_args
!($
($fmt
)+))
45 macro_rules
! task_debug
{
46 ($task
:expr
, $
($fmt
:tt
)+) => {{
47 $
crate::task
::TaskState
::log(&*$task
, log
::Level
::Debug
, &format_args
!($
($fmt
)+))
52 macro_rules
! task_trace
{
53 ($task
:expr
, $
($fmt
:tt
)+) => {{
54 $
crate::task
::TaskState
::log(&*$task
, log
::Level
::Trace
, &format_args
!($
($fmt
)+))