XFS

Struct XFS 

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

Main filesystem interface

Implementations§

Source§

impl XFS

Source

pub async fn connect( user: &str, consumer_key: &str, consumer_secret: &str, access_token: &str, access_token_secret: &str, ) -> Result<Self>

Connect to xfiles with Twitter OAuth 1.0a credentials

§Arguments
  • user - Twitter username (e.g., “@myagent”)
  • consumer_key - Twitter API Key
  • consumer_secret - Twitter API Secret
  • access_token - OAuth Access Token
  • access_token_secret - OAuth Access Token Secret

To get OAuth 1.0a credentials:

  1. Go to https://developer.twitter.com/en/portal/dashboard
  2. Create a project and app
  3. Under “Keys and tokens”, generate:
    • API Key & Secret (Consumer Key & Secret)
    • Access Token & Secret
  4. Ensure app has “Read and Write” permissions
§Example
let consumer_key = std::env::var("TWITTER_API_KEY").unwrap();
let consumer_secret = std::env::var("TWITTER_API_SECRET").unwrap();
let access_token = std::env::var("TWITTER_ACCESS_TOKEN").unwrap();
let access_token_secret = std::env::var("TWITTER_ACCESS_TOKEN_SECRET").unwrap();
let fs = XFS::connect("@myagent", &consumer_key, &consumer_secret,
                       &access_token, &access_token_secret).await?;
Source

pub async fn with_adapter( user: &str, adapter: Arc<dyn RemoteAdapter>, db_path: Option<&str>, ) -> Result<Self>

Create XFS with a custom adapter (useful for testing)

§Arguments
  • user - Username
  • adapter - Custom RemoteAdapter implementation
  • db_path - Optional custom database path
Source

pub async fn open(&mut self, path: &str, mode: OpenMode) -> Result<XFile>

Open a file

§Arguments
  • path - File path (e.g., “memory.txt” or “logs/agent.log”)
  • mode - How to open the file
Source

pub async fn list(&self, path: &str) -> Result<Vec<String>>

List files in a directory

§Arguments
  • path - Directory path (use “” or “/” for root)
Source

pub async fn history(&self, path: &str) -> Result<Vec<Commit>>

Get the history of a file

Returns all commits in chronological order

Source

pub async fn exists(&self, path: &str) -> Result<bool>

Check if a file exists

Source

pub fn user(&self) -> &str

Get the current user

Auto Trait Implementations§

§

impl Freeze for XFS

§

impl !RefUnwindSafe for XFS

§

impl Send for XFS

§

impl Sync for XFS

§

impl Unpin for XFS

§

impl !UnwindSafe for XFS

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