Struct bitcoin_primitives::AutoFile
source · pub struct AutoFile { /* private fields */ }Expand description
| Non-refcounted RAII wrapper for FILE* | | Will automatically close the file when | it goes out of scope if not null. | | If you’re returning the file pointer, | return file.release(). | | If you need to close the file early, use | file.fclose() instead of fclose(file). |
Implementations§
source§impl AutoFile
impl AutoFile
pub fn new(filenew: *mut FILE, n_type_in: i32, n_version_in: i32) -> Self
pub fn fclose(&mut self)
sourcepub fn release(&mut self) -> *mut FILE
pub fn release(&mut self) -> *mut FILE
| Get wrapped FILE* with transfer of ownership. | | ———– | @note | | This will invalidate the AutoFile | object, and makes it the responsibility | of the caller of this function to clean | up the returned FILE*. |
sourcepub fn get(&self) -> *mut FILE
pub fn get(&self) -> *mut FILE
| Get wrapped FILE* without transfer | of ownership. | | ———– | @note | | Ownership of the FILE* will remain with | this class. Use this only if the scope | of the | | AutoFile outlives use of the passed | pointer. |
sourcepub fn is_null(&self) -> bool
pub fn is_null(&self) -> bool
| Return true if the wrapped FILE* is nullptr, | false otherwise. |