Skip to content

Commit a971679

Browse files
bors[bot]codyps
andauthored
Merge #131
131: journal: move methods to JournalRef r=jmesmon a=jmesmon Co-authored-by: Cody P Schafer <[email protected]>
2 parents 32bd075 + 9fdc793 commit a971679

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

src/journal.rs

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use crate::ffi::array_to_iovecs;
33
use crate::ffi::journal as ffi;
44
use crate::id128::Id128;
55
use cstr_argument::CStrArgument;
6-
use foreign_types::{foreign_type, ForeignType};
6+
use foreign_types::{foreign_type, ForeignType, ForeignTypeRef};
77
use libc::{c_char, c_int, size_t};
88
use log::{self, Level, Log, Record, SetLoggerError};
99
use memchr::memchr;
@@ -242,7 +242,7 @@ pub struct DisplayEntryData<'a> {
242242
// iteration/next/previous)
243243
// - we have _total_ ownership over data iteration. Do what ever necessary to get all the data
244244
// we want
245-
journal: RefCell<&'a mut Journal>,
245+
journal: RefCell<&'a mut JournalRef>,
246246
}
247247

248248
impl<'a> fmt::Display for DisplayEntryData<'a> {
@@ -268,8 +268,8 @@ impl<'a> fmt::Display for DisplayEntryData<'a> {
268268
}
269269
}
270270

271-
impl<'a> From<&'a mut Journal> for DisplayEntryData<'a> {
272-
fn from(v: &'a mut Journal) -> Self {
271+
impl<'a> From<&'a mut JournalRef> for DisplayEntryData<'a> {
272+
fn from(v: &'a mut JournalRef) -> Self {
273273
Self {
274274
journal: RefCell::new(v),
275275
}
@@ -381,7 +381,9 @@ impl Journal {
381381
sd_try!(ffi::sd_journal_open_files(&mut jp, c_paths_ptr.as_ptr(), 0));
382382
Ok(unsafe { Journal::from_ptr(jp) })
383383
}
384+
}
384385

386+
impl JournalRef {
385387
/// Fields that are longer that this number of bytes _may_ be truncated when retrieved by this [`Journal`]
386388
/// instance.
387389
///
@@ -728,7 +730,7 @@ impl Journal {
728730

729731
/// Adds a match by which to filter the entries of the journal.
730732
/// If a match is applied, only entries with this field set will be iterated.
731-
pub fn match_add<T: Into<Vec<u8>>>(&mut self, key: &str, val: T) -> Result<&mut Journal> {
733+
pub fn match_add<T: Into<Vec<u8>>>(&mut self, key: &str, val: T) -> Result<&mut JournalRef> {
732734
let mut filter = Vec::<u8>::from(key);
733735
filter.push(b'=');
734736
filter.extend(val.into());
@@ -739,21 +741,21 @@ impl Journal {
739741
}
740742

741743
/// Inserts a disjunction (i.e. logical OR) in the match list.
742-
pub fn match_or(&mut self) -> Result<&mut Journal> {
744+
pub fn match_or(&mut self) -> Result<&mut JournalRef> {
743745
sd_try!(ffi::sd_journal_add_disjunction(self.as_ptr()));
744746
Ok(self)
745747
}
746748

747749
/// Inserts a conjunction (i.e. logical AND) in the match list.
748-
pub fn match_and(&mut self) -> Result<&mut Journal> {
750+
pub fn match_and(&mut self) -> Result<&mut JournalRef> {
749751
sd_try!(ffi::sd_journal_add_conjunction(self.as_ptr()));
750752
Ok(self)
751753
}
752754

753755
/// Flushes all matches, disjunction and conjunction terms.
754756
/// After this call all filtering is removed and all entries in
755757
/// the journal will be iterated again.
756-
pub fn match_flush(&mut self) -> Result<&mut Journal> {
758+
pub fn match_flush(&mut self) -> Result<&mut JournalRef> {
757759
unsafe { ffi::sd_journal_flush_matches(self.as_ptr()) };
758760
Ok(self)
759761
}

0 commit comments

Comments
 (0)