Skip to content

Commit 8571f3f

Browse files
committed
add some doc
1 parent 9bbfdba commit 8571f3f

File tree

1 file changed

+19
-4
lines changed

1 file changed

+19
-4
lines changed

log/src/lib.rs

+19-4
Original file line numberDiff line numberDiff line change
@@ -9,27 +9,31 @@ unsafe impl UriBound for EntryClass {
99
const URI: &'static [u8] = lv2_sys::LV2_LOG__Entry;
1010
}
1111

12+
/// UriBound for an error message.
1213
pub struct ErrorClass;
1314
unsafe impl UriBound for ErrorClass {
1415
const URI: &'static [u8] = lv2_sys::LV2_LOG__Error;
1516
}
1617

18+
/// UriBound for an informative message.
1719
pub struct NoteClass;
1820
unsafe impl UriBound for NoteClass {
1921
const URI: &'static [u8] = lv2_sys::LV2_LOG__Note;
2022
}
2123

24+
/// UriBound for a debuging message.
2225
pub struct TraceClass;
2326
unsafe impl UriBound for TraceClass {
2427
const URI: &'static [u8] = lv2_sys::LV2_LOG__Trace;
2528
}
2629

30+
/// Uribound for an error message.
2731
pub struct WarningClass;
2832
unsafe impl UriBound for WarningClass {
2933
const URI: &'static [u8] = lv2_sys::LV2_LOG__Warning;
3034
}
3135

32-
/// Marker for URID representing the nature of a log message
36+
/// Marker for URID representing the nature of a log message.
3337
// Note : it's may be better to have a URID trait to define a common interface
3438
pub unsafe trait EntryType
3539
where
@@ -59,7 +63,7 @@ unsafe impl EntryType for URID<WarningClass> {
5963
}
6064
}
6165

62-
/// Errors potentially generated by [`Log`](struct.Log.html) methods
66+
/// Errors potentially generated by [`Log`](struct.Log.html) methods.
6367
#[derive(PartialEq, Eq, Clone, Copy, Debug)]
6468
pub enum LogError {
6569
/// An error occured when sending message to the host
@@ -72,7 +76,7 @@ pub enum LogError {
7276
NoCallback,
7377
}
7478

75-
/// The Log feature
79+
/// The Log feature.
7680
#[repr(transparent)]
7781
pub struct Log<'a> {
7882
internal: &'a lv2_sys::LV2_Log_Log,
@@ -93,6 +97,17 @@ unsafe impl<'a> Feature for Log<'a> {
9397
}
9498

9599
impl<'a> Log<'a> {
100+
/// Send a log message to the host.
101+
///
102+
/// the `entry_type` parameter is an URID representing the kind of log message. There are four
103+
/// kind of message:
104+
/// * **note:** an informative message.
105+
/// * **warning:** a warning message.
106+
/// * **error:** an error message.
107+
/// * **trace:** a debugging trace. These entries should not be displayed during normal
108+
/// operation, but the host may implement an option to display them for debugging purposes.
109+
/// This entry type is special in that it may be written to in a real-time thread. It is
110+
/// assumed that if debug tracing is enabled, real-time considerations are not a concern.
96111
pub fn print(&self, entry_type: impl EntryType, message: &str) -> Result<(), LogError> {
97112
let printf = if let Some(printf) = self.internal.printf {
98113
printf
@@ -127,7 +142,7 @@ impl<'a> Log<'a> {
127142
}
128143
}
129144

130-
/// A URID cache containing all time properties.
145+
/// A URID cache containing all log properties.
131146
#[derive(URIDCollection, Debug)]
132147
pub struct LogURIDCollection {
133148
pub entry_class: URID<EntryClass>,

0 commit comments

Comments
 (0)