{"action":"created","issue":{"url":"https://api.github.com/repos/tz-lom/libarchive-sys/issues/5","labels_url":"https://api.github.com/repos/tz-lom/libarchive-sys/issues/5/labels{/name}","comments_url":"https://api.github.com/repos/tz-lom/libarchive-sys/issues/5/comments","events_url":"https://api.github.com/repos/tz-lom/libarchive-sys/issues/5/events","html_url":"https://github.com/tz-lom/libarchive-sys/issues/5","id":101406460,"number":5,"title":"Get libarchive-sys working on Rust stable?","user":{"login":"dginev","id":348975,"avatar_url":"https://avatars.githubusercontent.com/u/348975?v=3","gravatar_id":"","url":"https://api.github.com/users/dginev","html_url":"https://github.com/dginev","followers_url":"https://api.github.com/users/dginev/followers","following_url":"https://api.github.com/users/dginev/following{/other_user}","gists_url":"https://api.github.com/users/dginev/gists{/gist_id}","starred_url":"https://api.github.com/users/dginev/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dginev/subscriptions","organizations_url":"https://api.github.com/users/dginev/orgs","repos_url":"https://api.github.com/users/dginev/repos","events_url":"https://api.github.com/users/dginev/events{/privacy}","received_events_url":"https://api.github.com/users/dginev/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2015-08-17T12:08:49Z","updated_at":"2015-08-19T08:11:35Z","closed_at":null,"body":"The latest Rust nightly release just broke my project, as could be expected by new nightly releases.\r\n\r\nI would prefer developing on Rust \"beta\" or even \"stable\", however libarchive-sys is not compatible with the more \"solid\" Rust releases.\r\n\r\n@tz-lom : is there any chance that you have time to make that happen? I would love to help, but I am not informed enough on the steps that would be necessary to do the refactoring. "},"comment":{"url":"https://api.github.com/repos/tz-lom/libarchive-sys/issues/comments/132485600","html_url":"https://github.com/tz-lom/libarchive-sys/issues/5#issuecomment-132485600","issue_url":"https://api.github.com/repos/tz-lom/libarchive-sys/issues/5","id":132485600,"user":{"login":"dginev","id":348975,"avatar_url":"https://avatars.githubusercontent.com/u/348975?v=3","gravatar_id":"","url":"https://api.github.com/users/dginev","html_url":"https://github.com/dginev","followers_url":"https://api.github.com/users/dginev/followers","following_url":"https://api.github.com/users/dginev/following{/other_user}","gists_url":"https://api.github.com/users/dginev/gists{/gist_id}","starred_url":"https://api.github.com/users/dginev/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dginev/subscriptions","organizations_url":"https://api.github.com/users/dginev/orgs","repos_url":"https://api.github.com/users/dginev/repos","events_url":"https://api.github.com/users/dginev/events{/privacy}","received_events_url":"https://api.github.com/users/dginev/received_events","type":"User","site_admin":false},"created_at":"2015-08-19T08:11:35Z","updated_at":"2015-08-19T08:11:35Z","body":"So, I had a brief chat on IRC, as I suspected it was extremely helpful. Here is a summary, followed by the verbatim conversation:\r\n\r\n* We could, and actually should, avoid using ```Box::into_raw``` and ```Box::from_raw```, just do regular pointer casts between C and Rust instead\r\n* ReadContainer should be owned by Reader, for proper ownership\r\n* The [rustonomicon](https://doc.rust-lang.org/nightly/nomicon/) is still being written, but intends to capture as many of the \"unsafe\" details in Rust programming. Probably a good starting place to learn more.\r\n\r\nFull conversation:\r\n>[10:47 LLamaRider]  Hi Rust folks! The author of libarchive-sys (a libarchive wrapper for Rust) and I need some help with figuring out how to refactor his work to make it usable under \"stable\". So far it only work on \"nightly\". Our (brief) discussion is here: https://github.com/tz-lom/libarchive-sys/issues/5\r\n[10:47 LLamaRider]  actual code is here: https://github.com/tz-lom/libarchive-sys/blob/master/src/lib.rs\r\n[10:47 LLamaRider]  We both seem a bit novice to Rust, but if we get the idea, we can do the work\r\n[10:51 tomaka ] LLamaRider: Using Box::into_raw and Box::from_raw is totally wrong\r\n[10:52 tomaka ] LLamaRider: Box::from_raw should be replaced by just casting the raw pointer to a Rust pointer\r\n[10:52 tomaka ] LLamaRider: and the ReadContainer should be stored in the Reader struct for proper ownership\r\n[10:52 LLamaRider]  tomaka: Great! I (probably tz-lom also) know very little of the details, can you recommend either some doc or a repo that does this well?\r\n[10:53 LLamaRider]  I'll transfer your comments to GitHub in either case\r\n[10:54 tomaka ] maybe the advanced unsafe rust guide (or whatever it is called) talks about this\r\n[10:54 tomaka ] I haven't read it though, so it's just a guess\r\n[10:54 niconii ] \"the rustonomicon\", but i don't know either\r\n[10:55 niconii ] https://doc.rust-lang.org/nightly/nomicon/\r\n[10:55 niconii ] (\\still a work in progress though)\r\n[10:56 tomaka ] seems like a lot of read though\r\n[10:57 LLamaRider]  thanks a lot! Do you also happen to have a favourite wrapper that does something similar? Would help a lot to see \"stable\" code that is vaguely similar\r\n[10:57 tomaka ] LLamaRider: basically when you call archive_read_open you tell libarchive how to access the data\r\n[10:57 tomaka ] but you still have to make sure that the data stays alive for the duration of the operations\r\n[10:58 tomaka ] since you're guaranteed that libarchive will only access the data through calls to the member functions of \"Reader\"\r\n[10:58 tomaka ] you can just store that data in the \"Reader\" struct itself\r\n[10:58 tomaka ] probably inside an Option since there are situations where you don't need it\r\n[10:59 tomaka ] and when you interface with libarchive, just cast between raw pointers and Rust references\r\n[10:59 tomaka ] make sure to put the data in a Box though (but that's already the case in the current code), or its memory location will change if you move the Reader\r\n[11:00 tomaka ] when I say \"the data\" I'm talking about the `ReadContainer` struct"}}