rd-helpdb 0.0.1

Reader for installed R package help databases (aliases, .rdx/.rdb, Meta/hsearch.rds), built on rd-rds
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
//! Small shared helpers used across the crate.

use rd_rds::RStr;

use crate::Error;

/// Decodes an [`RStr`] to an owned [`String`], turning an NA string or a
/// string-decode failure into a crate-level [`Error`].
pub(crate) fn rstr_to_string(value: &RStr) -> Result<String, Error> {
    match value.as_str() {
        Some(Ok(text)) => Ok(text.into_owned()),
        Some(Err(err)) => Err(Error::Rds(err)),
        None => Err(Error::MalformedIndex("unexpected NA string".into())),
    }
}