Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

readme example does not compile #106

Open
matthiaskrgr opened this issue Feb 1, 2023 · 0 comments
Open

readme example does not compile #106

matthiaskrgr opened this issue Feb 1, 2023 · 0 comments
Labels
bug Something isn't working needs-review

Comments

@matthiaskrgr
Copy link

fn main() {
    

use cgroups_rs::*;
use cgroups_rs::cgroup_builder::*;

// Acquire a handle for the cgroup hierarchy.
let hier = cgroups_rs::hierarchies::auto();

// Use the builder pattern (see the documentation to create the control group)
//
// This creates a control group named "example" in the V1 hierarchy.
    let cg: Cgroup = CgroupBuilder::new("example")
        .cpu()
        .shares(85)
        .done()
        .build(hier);

// Now `cg` is a control group that gets 85% of the CPU time in relative to
// other control groups.

// Get a handle to the CPU controller.
let cpus: &cgroups_rs::cpu::CpuController = cg.controller_of().unwrap();
cpus.add_task(&CgroupPid::from(1234u64));

// [...]

// Finally, clean up and delete the control group.
cg.delete();

// Note that `Cgroup` does not implement `Drop` and therefore when the
// structure is dropped, the Cgroup will stay around. This is because, later
// you can then re-create the `Cgroup` using `load()`. We aren't too set on
// this behavior, so it might change in the feature. Rest assured, it will be a
// major version change.

}
error[E0308]: mismatched types
  --> src/main.rs:13:22
   |
13 |       let cg: Cgroup = CgroupBuilder::new("example")
   |  _____________------___^
   | |             |
   | |             expected due to this
14 | |         .cpu()
15 | |         .shares(85)
16 | |         .done()
17 | |         .build(hier);
   | |____________________^ expected `Cgroup`, found `Result<Cgroup, Error>`
   |
   = note: expected struct `cgroups_rs::Cgroup`
                found enum `Result<cgroups_rs::Cgroup, cgroups_rs::error::Error>`

For more information about this error, try `rustc --explain E0308`.
error: could not compile `cg` due to previous error

cgroups-rs 0.3

@matthiaskrgr matthiaskrgr added bug Something isn't working needs-review labels Feb 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working needs-review
Projects
None yet
Development

No branches or pull requests

1 participant