pub struct XFS { /* private fields */ }Expand description
Main filesystem interface
Implementations§
Source§impl XFS
impl XFS
Sourcepub async fn connect(
user: &str,
consumer_key: &str,
consumer_secret: &str,
access_token: &str,
access_token_secret: &str,
) -> Result<Self>
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 Keyconsumer_secret- Twitter API Secretaccess_token- OAuth Access Tokenaccess_token_secret- OAuth Access Token Secret
To get OAuth 1.0a credentials:
- Go to https://developer.twitter.com/en/portal/dashboard
- Create a project and app
- Under “Keys and tokens”, generate:
- API Key & Secret (Consumer Key & Secret)
- Access Token & Secret
- 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?;Sourcepub async fn with_adapter(
user: &str,
adapter: Arc<dyn RemoteAdapter>,
db_path: Option<&str>,
) -> Result<Self>
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- Usernameadapter- Custom RemoteAdapter implementationdb_path- Optional custom database path
Sourcepub async fn open(&mut self, path: &str, mode: OpenMode) -> Result<XFile>
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
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> 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
Mutably borrows from an owned value. Read more
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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>
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 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>
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