Skip to main content

NostrClient

Struct NostrClient 

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

Nostr client for git operations

Implementations§

Source§

impl NostrClient

Source

pub fn new( pubkey: &str, secret_key: Option<String>, url_secret: Option<[u8; 32]>, is_private: bool, config: &Config, ) -> Result<Self>

Create a new client with pubkey, optional secret key, url secret, is_private flag, and config

Source

pub fn can_sign(&self) -> bool

Check if we can sign (have secret key for this pubkey)

Source

pub fn list_repos(&self) -> Result<Vec<String>>

Source

pub async fn list_repos_async(&self) -> Result<Vec<String>>

Source

pub fn fetch_refs(&mut self, repo_name: &str) -> Result<HashMap<String, String>>

Fetch refs for a repository from nostr Returns refs parsed from the hashtree at the root hash

Source

pub fn fetch_refs_quick( &mut self, repo_name: &str, ) -> Result<HashMap<String, String>>

Fetch refs with a quick timeout (3s) for push operations Returns empty if timeout - allows push to proceed

Source

pub fn fetch_refs_with_root( &mut self, repo_name: &str, ) -> Result<(HashMap<String, String>, Option<String>, Option<[u8; 32]>)>

Fetch refs and root hash info from nostr Returns (refs, root_hash, encryption_key)

Source

pub fn update_ref( &mut self, repo_name: &str, ref_name: &str, sha: &str, ) -> Result<()>

Update a ref in local cache (will be published with publish_repo)

Source

pub fn delete_ref(&mut self, repo_name: &str, ref_name: &str) -> Result<()>

Delete a ref from local cache

Source

pub fn get_cached_root_hash(&self, repo_name: &str) -> Option<&String>

Get cached root hash for a repository

Source

pub fn get_cached_encryption_key(&self, repo_name: &str) -> Option<&[u8; 32]>

Get cached encryption key for a repository

Source

pub fn blossom(&self) -> &BlossomClient

Get the Blossom client for direct downloads

Source

pub fn relay_urls(&self) -> Vec<String>

Get the configured relay URLs

Source

pub fn pubkey(&self) -> &str

Get the public key (hex)

Source

pub fn npub(&self) -> String

Get the public key as npub bech32

Source

pub fn publish_repo( &self, repo_name: &str, root_hash: &str, encryption_key: Option<(&[u8; 32], bool, bool)>, ) -> Result<(String, RelayResult)>

Publish repository to nostr as kind 30078 event Format: kind: 30078 tags: [[“d”, repo_name], [“l”, “hashtree”], [“hash”, root_hash], [“key”|“encryptedKey”, encryption_key]] content: Returns: (npub URL, relay result with connected/failed details) If is_private is true, uses “encryptedKey” tag (XOR masked); otherwise uses “key” tag (plaintext CHK)

Source

pub fn fetch_prs( &self, repo_name: &str, state_filter: PullRequestStateFilter, ) -> Result<Vec<PullRequestListItem>>

Fetch pull requests targeting this repo, filtered by state.

Source

pub async fn fetch_prs_async( &self, repo_name: &str, state_filter: PullRequestStateFilter, ) -> Result<Vec<PullRequestListItem>>

Source

pub fn publish_pr_merged_status( &self, pr_event_id: &str, pr_author_pubkey: &str, ) -> Result<()>

Publish a kind 1631 (STATUS_APPLIED) event to mark a PR as merged

Source

pub async fn upload_blob(&self, _hash: &str, data: &[u8]) -> Result<String>

Upload blob to blossom server

Source

pub async fn upload_blob_if_missing( &self, data: &[u8], ) -> Result<(String, bool)>

Upload blob only if it doesn’t exist

Source

pub async fn download_blob(&self, hash: &str) -> Result<Vec<u8>>

Download blob from blossom server

Source

pub async fn try_download_blob(&self, hash: &str) -> Option<Vec<u8>>

Try to download blob, returns None if not found

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
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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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

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

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. 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.
Source§

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

Source§

fn vzip(self) -> V

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