Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FileReader implement Read Trait for The case like reading orc file #189

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

awol2005ex
Copy link
Contributor

FileReader implement Read Trait for The case like reading orc file

@Kimahriman
Copy link
Owner

I don't really want to implement a Sync trait in this library. If you need a Read you should be able to create your own wrapper object and implement Read on it with whatever semantics you need.

@awol2005ex
Copy link
Contributor Author

I don't really want to implement a Sync trait in this library. If you need a Read you should be able to create your own wrapper object and implement Read on it with whatever semantics you need.

The attr “position” is private so that the way of wrapper is impossible 。And “Read” Trait is very useful like that you can copy file very easy by the current tools。

@Kimahriman
Copy link
Owner

The attr “position” is private so that the way of wrapper is impossible

You can use the public remaining function to do the same thing

@awol2005ex
Copy link
Contributor Author

The attr “position” is private so that the way of wrapper is impossible

You can use the public remaining function to do the same thing

But FileReader is not impl Clone

@Kimahriman
Copy link
Owner

But FileReader is not impl Clone

If you need clone it probably isn't working correctly, since you would modify a cloned position instead of the original position. This seems to work fine:

struct FileReaderWrapper {
    inner: FileReader,
}

impl Read for FileReaderWrapper {
    fn read(&mut self, buf: &mut [u8]) -> std::io::Result<usize> {
        futures::executor::block_on(async { Ok(self.inner.read_buf(buf).await.unwrap()) })
    }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants