pub struct EuropePmcId {
pub source: EuropePmcSource,
pub id: String,
}Expand description
A fully-qualified Europe PMC record address: a (source, id) pair.
Fields§
§source: EuropePmcSourceThe source database.
id: StringThe record identifier within that source (e.g. a PMID for MED, or a
PMCnnn id for PMC).
Implementations§
Source§impl EuropePmcId
impl EuropePmcId
Sourcepub fn new(source: EuropePmcSource, id: impl Into<String>) -> Self
pub fn new(source: EuropePmcSource, id: impl Into<String>) -> Self
Construct an address from an explicit source and id.
Sourcepub fn pmc(id: &str) -> Result<Self>
pub fn pmc(id: &str) -> Result<Self>
Construct a PMC-sourced address, normalizing the id to PMCnnn form.
Accepts ids with or without the PMC prefix.
§Errors
Returns an error if the id is not a valid PMC id.
Sourcepub fn med(pmid: impl Into<String>) -> Self
pub fn med(pmid: impl Into<String>) -> Self
Construct a MED-sourced (PubMed) address from a PMID.
Sourcepub fn resolve(id: &str, source: Option<&str>) -> Result<Self>
pub fn resolve(id: &str, source: Option<&str>) -> Result<Self>
Resolve the (source, id) pair a caller addressed.
Europe PMC identifies every record by a source database plus an id, but requiring callers to spell both out for the common cases would be noise, so three forms are accepted:
- a fully-qualified
"SOURCE/ID"string (e.g."PPR/PPR123456"), which takes precedence over anysourceargument; - an explicit
sourceplus a bare id; - a bare id alone — a
PMC-prefixed id implies thePMCsource, anything else is treated as a PubMed (MED) record.
Every language binding routes its own id arguments through this so the three forms mean the same thing on every surface.
§Errors
Returns an error if the id is blank, or if a qualified or PMC-sourced
id is malformed.
§Examples
use pubmed_client::{EuropePmcId, EuropePmcSource};
// A bare PMC id implies the PMC source.
let id = EuropePmcId::resolve("PMC3258128", None)?;
assert_eq!(id.to_string(), "PMC/PMC3258128");
// A bare non-PMC id is treated as a PubMed record.
let id = EuropePmcId::resolve("33515491", None)?;
assert_eq!(id.to_string(), "MED/33515491");
// A qualified id wins over the source argument.
let id = EuropePmcId::resolve("PPR/PPR123456", Some("MED"))?;
assert_eq!(id.source, EuropePmcSource::Ppr);Trait Implementations§
Source§impl Clone for EuropePmcId
impl Clone for EuropePmcId
Source§fn clone(&self) -> EuropePmcId
fn clone(&self) -> EuropePmcId
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for EuropePmcId
impl Debug for EuropePmcId
Source§impl Display for EuropePmcId
impl Display for EuropePmcId
Source§impl FromStr for EuropePmcId
impl FromStr for EuropePmcId
Source§impl Hash for EuropePmcId
impl Hash for EuropePmcId
Source§impl PartialEq for EuropePmcId
impl PartialEq for EuropePmcId
impl Eq for EuropePmcId
impl StructuralPartialEq for EuropePmcId
Auto Trait Implementations§
impl Freeze for EuropePmcId
impl RefUnwindSafe for EuropePmcId
impl Send for EuropePmcId
impl Sync for EuropePmcId
impl Unpin for EuropePmcId
impl UnwindSafe for EuropePmcId
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more§impl<T> Pointable for T
impl<T> Pointable for T
§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
§impl<T> ToStringFallible for Twhere
T: Display,
impl<T> ToStringFallible for Twhere
T: Display,
§fn try_to_string(&self) -> Result<String, TryReserveError>
fn try_to_string(&self) -> Result<String, TryReserveError>
ToString::to_string, but without panic on OOM.