pub struct LinkProcessor { /* private fields */ }Expand description
A link Processor which collects the links from a Markdown and passes them on to
libimagentrylink functionality
The processor can be configured to
- Process internal links (from store entry to store entry)
- Process internal links with automatically creating targets If an internal link is encountered, the corrosponding target must be present in the store. If it is not, it will either be created or the processing fails
- Process external links (from store entry to URL)
- Process refs (from store entry to files on the filesystem and outside of the store) (default: false)
§Note
There’s no LinkProcessor::new() function, please use LinkProcessor::default().
Implementations§
Source§impl LinkProcessor
impl LinkProcessor
Sourcepub fn process_links(self, b: bool) -> Self
pub fn process_links(self, b: bool) -> Self
Switch internal link processing on/off
Internal links are links which are simply dirctory/file, but not /directory/file, as
beginning an id with / is discouraged in imag.
Sourcepub fn create_targets(self, b: bool) -> Self
pub fn create_targets(self, b: bool) -> Self
Switch internal link target creation on/off
If a link points to a non-existing imag entry, a false here will cause the processor to
return an error from process(). A true setting will create the entry and then fetch it
to link it to the processed entry.
Sourcepub fn process_urls(self, b: bool) -> Self
pub fn process_urls(self, b: bool) -> Self
Switch external link processing on/off
An external link must start with https:// or http://.
Sourcepub fn process_refs(self, b: bool) -> Self
pub fn process_refs(self, b: bool) -> Self
Switch ref processing on/off
A Ref is to be expected beeing a link with file::/// at the beginning.
Sourcepub fn process<'a>(&self, entry: &mut Entry, store: &'a Store) -> Result<()>
pub fn process<'a>(&self, entry: &mut Entry, store: &'a Store) -> Result<()>
Process an Entry for its links
§Notice
Whenever a “ref” is created, that means when a URL points to a filesystem path (normally
when using file:///home/user/foobar.file for example), the current implementation uses
libimagentryref to create make the entry into a ref.
The configuration of the libimagentryref::reference::Reference::make_ref() call is as
follows:
- Name of the collection: “root”
- Configuration:
{"root": "/"}
This implementation might change in the future, so that the configuration and the name of the collection can be passed to the function, or in a way that the user is asked what to do during the runtime of this function.
§Warning
When LinkProcessor::create_targets() was called to set the setting to true, this
function returns all errors returned by the Store.
That means:
- For an internal link, the linked target is created if create_targets() is true, else error
- For an external link, if create_targets() is true, libimagentrylink creates the external link entry, else the link is ignored
- all other cases do not create elements in the store
Trait Implementations§
Auto Trait Implementations§
impl Freeze for LinkProcessor
impl RefUnwindSafe for LinkProcessor
impl Send for LinkProcessor
impl Sync for LinkProcessor
impl Unpin for LinkProcessor
impl UnsafeUnpin for LinkProcessor
impl UnwindSafe for LinkProcessor
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> 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