File: progress.h

package info (click to toggle)
rust-rust-apt 0.8.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 620 kB
  • sloc: cpp: 703; makefile: 8
file content (42 lines) | stat: -rw-r--r-- 1,022 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#pragma once
#include <apt-pkg/install-progress.h>
#include <apt-pkg/progress.h>
#include "rust/cxx.h"

#include "rust-apt/src/progress.rs"

struct OpProgressWrapper : public OpProgress {
	/// Callback to the rust struct
	OperationProgress& callback;

	void Update() { callback.update(Op, Percent); };
	void Done() { callback.done(); };

	OpProgressWrapper(OperationProgress& callback) : callback(callback){};
};

struct PackageManagerWrapper : public APT::Progress::PackageManagerFancy {
	/// Callback to the rust struct
	InstallProgress& callback;

	bool StatusChanged(
		std::string pkgname,
		unsigned int steps_done,
		unsigned int total_steps,
		std::string action
	) {
		callback.status_changed(pkgname, steps_done, total_steps, action);
		return true;
	};

	void Error(
		std::string pkgname,
		unsigned int steps_done,
		unsigned int total_steps,
		std::string error
	) {
		callback.error(pkgname, steps_done, total_steps, error);
	};

	PackageManagerWrapper(InstallProgress& callback) : callback(callback){};
};