Skip to main content

Source

Struct Source 

Source
pub struct Source<F> {
    pub file: Option<FileSource<F>>,
}
Expand description

Where a table is kept: an object holding exactly one source kind, open to more kinds (a SQL database, an HTTP API) without changing what sits beside it.

F is the caller’s format choice, a Codec that is also configuration (an enum of the formats a plugin offers). In a configuration:

{ "file": { "path": "accounts.toml", "format": "toml" } }

Fields§

§file: Option<FileSource<F>>

Records in one private file.

Implementations§

Source§

impl<F> Source<F>

Source

pub fn file(path: impl Into<String>, format: F) -> Self

The file at path, written in format.

Source

pub fn max_bytes(self, max: u32) -> Self

This source with a size bound, in bytes, for the file.

Source

pub fn max_bytes_unless_set(self, max: u32) -> Self

This source with max as the size bound, unless one is set: a provider sizes the default from the number of records it allows.

Source

pub fn sibling(&self, suffix: &str) -> Self
where F: Clone,

The same kind of source beside this one, for a second table: a file source becomes the file named <path>.<suffix> in the same format.

Source

pub fn open<T>(&self, section: &str) -> Result<Arc<dyn Table<T>>, SourceError>
where F: Codec + Clone + 'static, T: Keyed + Clone + Send + Walk + FromWalk + 'static,

The table of T under section this source names. Nothing is read yet.

§Errors

SourceError::Invalid when no source kind is set or the file’s path is blank.

Trait Implementations§

Source§

impl<F: Clone> Clone for Source<F>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<F: Debug> Debug for Source<F>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<F> Describe for Source<F>
where F: Describe + Inspect,

Source§

type Fill = __Fill<F>

The partly filled state of this type: what Partial holds.
Source§

fn description() -> Description

What this type is.
§

const OPTIONAL: bool = false

The type is Option<_>: leaving a field of it out is a value of its own, so it is never required.
§

const LEAF: bool = false

The type is one text: a [Leaf], or an untagged enum whose arms all are. An untagged enum counts the arms that are not, and holds at most one.
Source§

impl<F: Eq> Eq for Source<F>

Source§

impl<F> Fields for Source<F>
where F: Describe + Inspect,

Source§

impl<F> Inspect for Source<F>
where F: Describe + Inspect,

Source§

fn at(&self, __at: &[Segment]) -> Option<Datum>

The leaf at at, or None.
Source§

fn entries(&self, __at: &[Segment]) -> Option<Entries>

The structure at at, or None.
Source§

impl<F: PartialEq> PartialEq for Source<F>

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl<F: PartialEq> StructuralPartialEq for Source<F>

Auto Trait Implementations§

§

impl<F> Freeze for Source<F>
where F: Freeze,

§

impl<F> RefUnwindSafe for Source<F>
where F: RefUnwindSafe,

§

impl<F> Send for Source<F>
where F: Send,

§

impl<F> Sync for Source<F>
where F: Sync,

§

impl<F> Unpin for Source<F>
where F: Unpin,

§

impl<F> UnsafeUnpin for Source<F>
where F: UnsafeUnpin,

§

impl<F> UnwindSafe for Source<F>
where F: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.