oku_fs::database::core

Struct OkuDatabase

Source
pub struct OkuDatabase { /* private fields */ }
Expand description

The database used by Oku’s protocol.

Implementations§

Source§

impl OkuDatabase

Source

pub fn new() -> Result<Self>

Open an existing Oku database, or create one if it does not exist.

§Returns

An Oku database.

Source

pub fn migrate(&self) -> Result<()>

Perform a database migration.

Source§

impl OkuDatabase

Source

pub fn upsert_announcement( &self, announcement: &ReplicaAnnouncement, ) -> Result<Option<ReplicaAnnouncement>>

Insert or update a replica announcement record.

§Arguments
  • announcement - A replica announcement record to upsert.
§Returns

The previous record of the announcement, if one existed.

Source

pub fn upsert_announcements( &self, announcements: &[ReplicaAnnouncement], ) -> Result<Vec<Option<ReplicaAnnouncement>>>

Insert or update multiple replica announcement records.

§Arguments
  • announcements - A list of replica announcement records to upsert.
§Returns

A list containing the previous record of each announcement, if one existed.

Source

pub fn delete_announcement( &self, announcement: &ReplicaAnnouncement, ) -> Result<ReplicaAnnouncement>

Delete a replica announcement record.

§Arguments
  • announcement - A replica announcement record to delete.
§Returns

The deleted replica announcement record.

Source

pub fn delete_announcements( &self, announcements: &[ReplicaAnnouncement], ) -> Result<Vec<ReplicaAnnouncement>>

Delete multiple replica announcement records.

§Arguments
  • announcements - A list of replica announcement records to delete.
§Returns

A list containing the deleted replica announcement records.

Source

pub fn get_announcements(&self) -> Result<Vec<ReplicaAnnouncement>>

Gets the replica announcements recorded by this node.

§Returns

The replica announcements recorded by this node.

Source

pub fn get_announcement( &self, key: &Vec<u8>, ) -> Result<Option<ReplicaAnnouncement>>

Gets a replica announcement record by its public key.

§Arguments
  • key - The public key of the DHT announcement.
§Returns

A replica announcement record.

Source§

impl OkuDatabase

Source

pub fn search_posts( query_string: &str, result_limit: &Option<usize>, ) -> Result<Vec<OkuPost>>

Search OkuNet posts with a query string.

§Arguments
  • query_string - The string used to query for posts.

  • result_limit - The maximum number of results to get (defaults to 10).

§Returns

A list of OkuNet posts.

Source

pub fn upsert_post(&self, post: &OkuPost) -> Result<Option<OkuPost>>

Insert or update an OkuNet post.

§Arguments
  • post - An OkuNet post to upsert.
§Returns

The previous version of the post, if one existed.

Source

pub fn upsert_posts(&self, posts: &Vec<OkuPost>) -> Result<Vec<Option<OkuPost>>>

Insert or update multiple OkuNet posts.

§Arguments
  • posts - A list of OkuNet posts to upsert.
§Returns

A list containing the previous version of each post, if one existed.

Source

pub fn delete_post(&self, post: &OkuPost) -> Result<OkuPost>

Delete an OkuNet post.

§Arguments
  • post - An OkuNet post to delete.
§Returns

The deleted post.

Source

pub fn delete_posts(&self, posts: &[OkuPost]) -> Result<Vec<OkuPost>>

Delete multiple OkuNet posts.

§Arguments
  • posts - A list of OkuNet posts to delete.
§Returns

A list containing the deleted posts.

Source

pub fn get_posts(&self) -> Result<Vec<OkuPost>>

Retrieves all known OkuNet posts.

§Returns

A list of all known OkuNet posts.

Source

pub fn get_posts_by_author(&self, author_id: &AuthorId) -> Result<Vec<OkuPost>>

Retrieves all known OkuNet posts by a given author.

§Arguments
  • author_id - A content authorship ID.
§Returns

A list of all known OkuNet posts by the given author.

Source

pub fn get_posts_by_tag(&self, tag: &String) -> Result<Vec<OkuPost>>

Retrieves all known OkuNet posts by a given tag.

§Arguments
  • tag - A tag.
§Returns

A list of all known OkuNet posts with the given tag.

Source

pub fn get_tags(&self) -> Result<HashSet<String>>

Retrieves all distinct tags used in OkuNet posts.

§Returns

A list of all tags that appear in an OkuNet post.

Source

pub fn get_post( &self, author_id: &AuthorId, path: &PathBuf, ) -> Result<Option<OkuPost>>

Retrieves an OkuNet post.

§Arguments
  • author_id - A content authorship ID.

  • path - A path to a post in the author’s home replica.

§Returns

The OkuNet post by the given author at the given path, if one exists.

Source§

impl OkuDatabase

Source

pub fn upsert_user(&self, user: &OkuUser) -> Result<Option<OkuUser>>

Insert or update an OkuNet user.

§Arguments
  • user - An OkuNet user to upsert.
§Returns

The previous version of the user, if one existed.

Source

pub fn delete_user(&self, user: &OkuUser) -> Result<OkuUser>

Delete an OkuNet user.

§Arguments
  • user - An OkuNet user to delete.
§Returns

The deleted user.

Source

pub fn delete_users(&self, users: &[OkuUser]) -> Result<Vec<OkuUser>>

Delete multiple OkuNet users.

§Arguments
  • users - A list of OkuNet users to delete.
§Returns

A list containing the deleted users.

Source

pub fn delete_users_with_posts(&self, users: &[OkuUser]) -> Result<Vec<OkuPost>>

Delete multiple OkuNet users and their posts.

§Arguments
  • users - A list of OkuNet users to delete.
§Returns

A list containing the deleted posts.

Source

pub fn delete_by_author_ids(&self, author_ids: &Vec<AuthorId>) -> Result<()>

Deletes OkuNet users by their author IDs and posts by authors with those IDs.

Differs from Self::delete_users_with_posts as a post will still be deleted even if a record for the authoring user is not found.

§Arguments
  • author_ids - A list of content authorship IDs.
Source

pub fn all_local_users(&self) -> Vec<AuthorId>

Gets the content authorship IDs of all locally-known users.

This differs from Self::get_users as IDs of authors with posts but no user records are included.

§Returns

A list of IDs for all users that have content in the local database.

Source

pub fn get_users(&self) -> Result<Vec<OkuUser>>

Gets the OkuNet content of all known users.

§Returns

The OkuNet content of all users known to this node.

Source

pub fn get_user(&self, author_id: &AuthorId) -> Result<Option<OkuUser>>

Gets an OkuNet user’s content by their content authorship ID.

§Arguments
  • author_id - A content authorship ID.
§Returns

An OkuNet user’s content.

Auto Trait Implementations§

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
§

impl<'a, T, E> AsTaggedExplicit<'a, E> for T
where T: 'a,

§

fn explicit(self, class: Class, tag: u32) -> TaggedParser<'a, Explicit, Self, E>

§

impl<'a, T, E> AsTaggedImplicit<'a, E> for T
where T: 'a,

§

fn implicit( self, class: Class, constructed: bool, tag: u32, ) -> TaggedParser<'a, Implicit, Self, E>

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
§

impl<T> Downcast for T
where T: Any,

§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.
§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
§

fn as_any(&self) -> &(dyn Any + 'static)

Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
§

impl<T> DowncastSync for T
where T: Any + Send + Sync,

§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Send + Sync>

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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<F, T> IntoSample<T> for F
where T: FromSample<F>,

§

fn into_sample(self) -> T

§

impl<D> OwoColorize for D

§

fn fg<C>(&self) -> FgColorDisplay<'_, C, Self>
where C: Color,

Set the foreground color generically Read more
§

fn bg<C>(&self) -> BgColorDisplay<'_, C, Self>
where C: Color,

Set the background color generically. Read more
§

fn black(&self) -> FgColorDisplay<'_, Black, Self>

Change the foreground color to black
§

fn on_black(&self) -> BgColorDisplay<'_, Black, Self>

Change the background color to black
§

fn red(&self) -> FgColorDisplay<'_, Red, Self>

Change the foreground color to red
§

fn on_red(&self) -> BgColorDisplay<'_, Red, Self>

Change the background color to red
§

fn green(&self) -> FgColorDisplay<'_, Green, Self>

Change the foreground color to green
§

fn on_green(&self) -> BgColorDisplay<'_, Green, Self>

Change the background color to green
§

fn yellow(&self) -> FgColorDisplay<'_, Yellow, Self>

Change the foreground color to yellow
§

fn on_yellow(&self) -> BgColorDisplay<'_, Yellow, Self>

Change the background color to yellow
§

fn blue(&self) -> FgColorDisplay<'_, Blue, Self>

Change the foreground color to blue
§

fn on_blue(&self) -> BgColorDisplay<'_, Blue, Self>

Change the background color to blue
§

fn magenta(&self) -> FgColorDisplay<'_, Magenta, Self>

Change the foreground color to magenta
§

fn on_magenta(&self) -> BgColorDisplay<'_, Magenta, Self>

Change the background color to magenta
§

fn purple(&self) -> FgColorDisplay<'_, Magenta, Self>

Change the foreground color to purple
§

fn on_purple(&self) -> BgColorDisplay<'_, Magenta, Self>

Change the background color to purple
§

fn cyan(&self) -> FgColorDisplay<'_, Cyan, Self>

Change the foreground color to cyan
§

fn on_cyan(&self) -> BgColorDisplay<'_, Cyan, Self>

Change the background color to cyan
§

fn white(&self) -> FgColorDisplay<'_, White, Self>

Change the foreground color to white
§

fn on_white(&self) -> BgColorDisplay<'_, White, Self>

Change the background color to white
§

fn default_color(&self) -> FgColorDisplay<'_, Default, Self>

Change the foreground color to the terminal default
§

fn on_default_color(&self) -> BgColorDisplay<'_, Default, Self>

Change the background color to the terminal default
§

fn bright_black(&self) -> FgColorDisplay<'_, BrightBlack, Self>

Change the foreground color to bright black
§

fn on_bright_black(&self) -> BgColorDisplay<'_, BrightBlack, Self>

Change the background color to bright black
§

fn bright_red(&self) -> FgColorDisplay<'_, BrightRed, Self>

Change the foreground color to bright red
§

fn on_bright_red(&self) -> BgColorDisplay<'_, BrightRed, Self>

Change the background color to bright red
§

fn bright_green(&self) -> FgColorDisplay<'_, BrightGreen, Self>

Change the foreground color to bright green
§

fn on_bright_green(&self) -> BgColorDisplay<'_, BrightGreen, Self>

Change the background color to bright green
§

fn bright_yellow(&self) -> FgColorDisplay<'_, BrightYellow, Self>

Change the foreground color to bright yellow
§

fn on_bright_yellow(&self) -> BgColorDisplay<'_, BrightYellow, Self>

Change the background color to bright yellow
§

fn bright_blue(&self) -> FgColorDisplay<'_, BrightBlue, Self>

Change the foreground color to bright blue
§

fn on_bright_blue(&self) -> BgColorDisplay<'_, BrightBlue, Self>

Change the background color to bright blue
§

fn bright_magenta(&self) -> FgColorDisplay<'_, BrightMagenta, Self>

Change the foreground color to bright magenta
§

fn on_bright_magenta(&self) -> BgColorDisplay<'_, BrightMagenta, Self>

Change the background color to bright magenta
§

fn bright_purple(&self) -> FgColorDisplay<'_, BrightMagenta, Self>

Change the foreground color to bright purple
§

fn on_bright_purple(&self) -> BgColorDisplay<'_, BrightMagenta, Self>

Change the background color to bright purple
§

fn bright_cyan(&self) -> FgColorDisplay<'_, BrightCyan, Self>

Change the foreground color to bright cyan
§

fn on_bright_cyan(&self) -> BgColorDisplay<'_, BrightCyan, Self>

Change the background color to bright cyan
§

fn bright_white(&self) -> FgColorDisplay<'_, BrightWhite, Self>

Change the foreground color to bright white
§

fn on_bright_white(&self) -> BgColorDisplay<'_, BrightWhite, Self>

Change the background color to bright white
§

fn bold(&self) -> BoldDisplay<'_, Self>

Make the text bold
§

fn dimmed(&self) -> DimDisplay<'_, Self>

Make the text dim
§

fn italic(&self) -> ItalicDisplay<'_, Self>

Make the text italicized
§

fn underline(&self) -> UnderlineDisplay<'_, Self>

Make the text underlined
Make the text blink
Make the text blink (but fast!)
§

fn reversed(&self) -> ReversedDisplay<'_, Self>

Swap the foreground and background colors
§

fn hidden(&self) -> HiddenDisplay<'_, Self>

Hide the text
§

fn strikethrough(&self) -> StrikeThroughDisplay<'_, Self>

Cross out the text
§

fn color<Color>(&self, color: Color) -> FgDynColorDisplay<'_, Color, Self>
where Color: DynColor,

Set the foreground color at runtime. Only use if you do not know which color will be used at compile-time. If the color is constant, use either [OwoColorize::fg] or a color-specific method, such as [OwoColorize::green], Read more
§

fn on_color<Color>(&self, color: Color) -> BgDynColorDisplay<'_, Color, Self>
where Color: DynColor,

Set the background color at runtime. Only use if you do not know what color to use at compile-time. If the color is constant, use either [OwoColorize::bg] or a color-specific method, such as [OwoColorize::on_yellow], Read more
§

fn fg_rgb<const R: u8, const G: u8, const B: u8>( &self, ) -> FgColorDisplay<'_, CustomColor<R, G, B>, Self>

Set the foreground color to a specific RGB value.
§

fn bg_rgb<const R: u8, const G: u8, const B: u8>( &self, ) -> BgColorDisplay<'_, CustomColor<R, G, B>, Self>

Set the background color to a specific RGB value.
§

fn truecolor(&self, r: u8, g: u8, b: u8) -> FgDynColorDisplay<'_, Rgb, Self>

Sets the foreground color to an RGB value.
§

fn on_truecolor(&self, r: u8, g: u8, b: u8) -> BgDynColorDisplay<'_, Rgb, Self>

Sets the background color to an RGB value.
§

fn style(&self, style: Style) -> Styled<&Self>

Apply a runtime-determined style
§

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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
§

impl<T> ErasedDestructor for T
where T: 'static,

§

impl<T> Fruit for T
where T: Send + Downcast,

§

impl<T> MaybeSendSync for T