Skip to content

Refactor ssl module#3147

Merged
youknowone merged 1 commit into
RustPython:mainfrom
youknowone:ssl-module
Sep 27, 2021
Merged

Refactor ssl module#3147
youknowone merged 1 commit into
RustPython:mainfrom
youknowone:ssl-module

Conversation

@youknowone

Copy link
Copy Markdown
Member

I moved io::Read and io::Write for PySocketRef to ssl. If they are implemented for PySocket, it would be member of socket. But the PyRef<PySocket> requirement is decided by ssl::SslStream. not by socket itself. So I moved it to ssl to make them specific to ssl requirement.

part of #3104

Comment thread vm/src/stdlib/socket.rs Outdated
}

fn sock_io(&self) -> io::Result<PyMappedRwLockReadGuard<'_, Socket>> {
pub(crate) fn sock_io(&self) -> io::Result<PyMappedRwLockReadGuard<'_, Socket>> {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe it would make sense to expose a pub send(&[u8]) -> io::Result<usize> and recv(&mut [u8]) -> io::Result<usize> for once the stdlib gets moved out of rustpython-vm oh I guess socket is also in stdlib. But the above still seems like a better abstraction than exposing ReadGuard.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(and flush() for sockets is a no-op)

@youknowone youknowone Sep 27, 2021

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks. I implemented io::Read and io::Write for &PySocket and used it from ssl

@youknowone youknowone merged commit 837bf59 into RustPython:main Sep 27, 2021
@youknowone youknowone deleted the ssl-module branch September 27, 2021 08:12
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